赞
踩
##标注排序修改breaks,breaks——labels,
p + scale_colour_discrete(#values=c("#CC0000", "#006600", "#669999",
# "#00CCCC", "#660099"),或者color/fill/colour,discrete/hue,
name="Experimental",
breaks = c("6","4","8"),
labels = c("B","A","C"))
##第一种color/fill/colour,discrete/hue
p + scale_colour_discrete(
name="Experimental",
breaks = c("6","4","8"),
labels = c("B","A","C"))
##第二种修改图例标题
p + labs(colour = "name1", shape = "name2")
#第一种,
#Remove title for fill legend
p + guides(colour=guide_legend(title=NULL)) #注意colour/fill/color/shape转换
#第二种,所有的表题全部移除
# Remove title for all legends
p + theme(legend.title=element_blank())
#1: around the plot "none", "left", "right", "bottom", "top"
basic + theme(legend.position = "bottom")
#2:inside the plot
basic + theme(
legend.position = c(.95, .95),#plot内位置
legend.justification = c("right", "top"),#固定右上角
legend.background = element_blank(),#图例背景色
legend.key = element_blank(),#图标背景色element_rect(colour="black")
legend.box.background = element_rect(fill=NA,color = "black",linetype = 1) #图例外框和背景色默认填充白色(删除fill=NA)
#legend.box.just = "right",
#legend.margin = margin(6, 6, 6, 6)#边框大小调整
)
#删除其中一个图例
guides(shape=FALSE) #shape/color/colour/fill
#全部删除图例
theme(legend.position = "none")
R语言之可视化①⑨子ggplot2中的图例修改
ggplot2-设置图例(legend)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。