theme(legend.position = "left") p 2. 内部图例的位置控制 在上述图中,“cyl” 变量的图例在图的中间。在 ggplot2 的以前版本中,可以将legend.position设置为一个坐标来控制位置。然而,这样做会改变默认的图例位置,这并不总是理想的。为了涵盖这种情况,现在有一个专门的legend.position.inside参数,无论位置是...
theme(legend.position = "none") # Position the legend at the bottom of the plot plt_prop_unemployed_over_time + theme(legend.position ="bottom") # Position the legend inside the plot at (0.6, 0.1) plt_prop_unemployed_over_time + theme(legend.position =c(0.6,0.1)) Modifying theme elem...
其中legend.justification参数可以将图例设置在图中,legend.position参数用来将图例设置在图表区域,其中x和y轴的位置(0,0)是在图表的左下和(1,1)是右上角。 # No legend ---p+theme(legend.position="None")+labs(subtitle="No Legend")# legend at the bottom and horizontal ---p+theme(legend.position=...
其中legend.justification参数可以将图例设置在图中,legend.position参数用来将图例设置在图表区域,其中x和y轴的位置(0,0)是在图表的左下和(1,1)是右上角。 代码语言:javascript 复制 # No legend---p+theme(legend.position="None")+labs(subtitle="No Legend")# legend at the bottom and horizontal---p+...
p+theme(legend.position = "bottom")#图例在底部 #也可以自定义 p+theme(legend.position = c(0.5, 0.7)) #为图例加边界 p+theme(legend.background = element_rect(color="red")) #或者为图例中的每个元素进行设置,如加边界 p+theme(legend.key =element_rect(color="red")) ...
图例是主题的一个方面,因此可以使用theme()功能进行修改。其中legend.justification参数可以将图例设置在图中,legend.position参数用来将图例设置在图表区域,其中x和y轴的位置(0,0)是在图表的左下和(1,1)是右上角。 # No legend ---p + theme(legend.position="None") + labs(subtitle="No Legend")# legen...
p+theme(legend.position = "bottom")#图例在底部 #也可以自定义 p+theme(legend.position = c(0.5, 0.7)) #为图例加边界 p+theme(legend.background = element_rect(color="red")) #或者为图例中的每个元素进行设置,如加边界 p+theme(legend.key =element_rect(color="red")) ...
legend.box = "horizontal") + labs(subtitle="Legend bottom") # legend at bottom-right, inside the plot ---p + theme(legend.title = element_text(size=12, color = "salmon", face="bold"), legend.justification=c(1,0), legend.position=c(0.95, 0.05), legend.background = element_blank...
ggplot(housing,aes(x=State,y=Home.Price.Index))+theme(legend.position="top",axis.text=element_text(size=6))+geom_point(aes(color=Date),alpha=0.5,size=1.5,position=position_jitter(width=0.25,height=0)))+scale_color_continuous(name="",breaks=c(1976,1994,2013),labels=c("'76","'94",...
bp + theme(legend.position="top") It is also possible to position the legend inside the plotting area. Note that the numeric position below is relative to the entire area, including titles and labels, not just the plotting area. # Position legend in graph, where x,y is 0,0 (bottom ...