검은 색 배경의 ggplot2 테마를 사용하는 경우 색상 가이드 이외의 안내선에 대한 범례 색상을 제어하여 사물이 검은 색으로 그려지지 않도록 할 수 있습니까? 그렇다면 어떻게? 그것은 눈에 보이지 않는, 그래서 ggplot의 색상 가이드가 아닌 범례 요소의 색상을 제어하십시오.
library(ggplot2) # needs to be 0.9.3 for this theme
data(iris) # included with ggplot2
theme_black<- function (base_size = 16, base_family = ""){
theme_minimal() %+replace%
theme(
line = element_line(colour = "white", size = 0.5, linetype = 1,
lineend = "butt"),
rect = element_rect(fill = "white",
colour = "white", size = 0.5, linetype = 1),
text = element_text(family = base_family,
face = "plain", colour = "white", size = base_size,
angle = 0, lineheight = 0.9, hjust = 0, vjust = 0),
plot.background = element_rect(colour = 'black', fill = 'black'),
plot.title = element_text(size = rel(1.2)),
panel.border = element_rect(fill = NA, colour = "white"),
panel.grid.major = element_line(colour = "grey20", size = 0.2),
panel.grid.minor = element_line(colour = "grey5", size = 0.5),
strip.background = element_rect(fill = "grey30", colour = "grey30")
)
}
ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, shape=Species,
colour=Petal.Length))+geom_point()+theme_black()+
scale_colour_gradient(low = "purple", high = "white")
당신이 볼 수 있듯이
는 전설의 형상 부분에 대한 기본 색상은 변경되지 않은 하나는 어떤 종 알 수없는 :내가 지금 가지고있는 유일한 해결책은 전설을 바꾸는 것이다. 배경색은 잉크의 낭비이다.
다음은 부분적인 수정입니다 :'+ guides (shape = guide_legend (override.aes = list (color = "white")))'. 불행히도,'theme()'는 기본 포인트 컬러 같은 것들을 변경하는 데 사용할 수 없습니다. – bdemarest
답장을 보내 주셔서 감사합니다 (+1). 나는 그것이 대답으로 추가할만한 가치가 있다고 생각한다 : 나는 분명히 그것을 upvote 할 것이다. – MattBagg