[英]Difference theme legend position and show.legend
I am studying ggplot2
Elegant Graphics for Data Analysis.我正在研究用于数据分析的
ggplot2
优雅图形。 What difference both code are?两个代码有什么区别?
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point(show.legend = FALSE) +
directlabels::geom_dl(aes(label = class), method = "smart.grid")
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
theme(legend.position = "none") +
directlabels::geom_dl(aes(label = class), method = "smart.grid")
both create this plot都创造了这个情节
I wonder when I use show.legend = FALSE
我想知道我
show.legend = FALSE
时候使用show.legend = FALSE
From ?geom_point
从
?geom_point
show.legend: logical.
show.legend:合乎逻辑。 Should this layer be included in the legends?
这个层应该包含在图例中吗? 'NA', the default, includes if any aesthetics are mapped.
'NA' 是默认值,包括是否映射了任何美学。 'FALSE' never includes, and 'TRUE' always includes.
'FALSE' 从不包括,而 'TRUE' 总是包括。 It can also be a named logical vector to finely select the aesthetics to display.
它也可以是一个命名的逻辑向量,以精细选择要显示的美学。
From ?theme
从
?theme
legend.position: the position of legends ("none", "left", "right", "bottom", "top", or two-element numeric vector)
legend.position:图例的位置(“none”、“left”、“right”、“bottom”、“top”或二元数值向量)
theme(legend.position = "none")
disables all legends, geom_point(..., show.legends = FALSE)
disables the legend for this (ie the geom_point
) layer. theme(legend.position = "none")
禁用所有图例, geom_point(..., show.legends = FALSE)
禁用此层(即geom_point
)的geom_point
。
For example例如
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point(show.legend = FALSE) +
geom_label(aes(label = class)) +
directlabels::geom_dl(aes(label = class), method = "smart.grid")
shows no legend for geom_point
, but does show a legend for geom_label
.不显示
geom_point
,但显示geom_label
的图例。
On the other hand,另一方面,
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point() +
geom_label(aes(label = class)) +
theme(legend.position = "none") +
directlabels::geom_dl(aes(label = class), method = "smart.grid")
disables all legends.禁用所有图例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.