r-legend-title-none-1

ggplot2でグラフを作っていて、「レジェンドは要るけど、レジェンドタイトルは消したいな」と思って消した時の備忘録。

r-legend-title-none-1

使う関数は「theme」のlegend.title = element_blank

theme(legend.title = element_blank())

無事に消えた。

r-legend-title-none-2

全体のコードは下記。

ggplot(Data2,
aes(x = Age,
y = `XX positive area [%]`,
fill = Genotype)) +
stat_summary(
fun = "mean",
geom = "bar",
position = "dodge",
colour = "black") +
scale_fill_manual(values = c("#CCCCCC","#444444")
) +
facet_wrap(~Region) +
stat_summary(
fun = "mean",
fun.min = function(x)mean(x) - sd(x)/sqrt(4),
fun.max = function(x)mean(x) + sd(x)/sqrt(4),
geom = "errorbar", position = position_dodge(.9),
width = .5, size = .1,
colour = "black",
) +
geom_point(
position = position_jitterdodge(
jitter.width = .45, 
jitter.height = 0 
),
size = 2.5, 
colour = "black", 
aes(shape = Genotype) 
) +
scale_shape_manual( 
values = c(21, 17)
) +
scale_y_break(c(15,19), scale = 0.5) +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(size = 20, hjust = .45),
axis.title.y = element_text(size = 20),
axis.text.x = element_text(size = 15),
axis.text.y = element_text(size = 15),
strip.text.x = element_text(size = 15)
)
にほんブログ村 子育てブログ ワーキングマザー育児へ