黒の背景を持つ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")
あなたが見ることができるようにそれが見えないので、伝説の形状部分のデフォルトの色は、変更されていない、もう1つはこれである種の言うことはできません。
今私が持っている解決策はlegend.backgroundの色を変更することですが、これはインクと醜いの無駄です。
これは部分的な修正です: '+ guides(shape = guide_legend(override.aes = list(color =" white ")))'。残念ながら、 'theme()'はデフォルトのポイントカラーのようなものを変更するためには使用できません。 – bdemarest
この返答ありがとうございます(+1)。私は答えとして追加する価値があると思う:私は確かにそれをupvoteだろう。 – MattBagg