[关闭]
@Macux 2015-12-01T06:46:35.000000Z 字数 816 阅读 901

R语言_ggplot2_Lv2_OverAllAppearance

R语言_学习笔记


  1. > p1 <- ggplot(heightweight,aes(ageYear,heightIn)) + geom_point(shape=8,color="black")
  2. > p1 + ggtitle("Age and Height of Schoolchildren") +theme(plot.title=element_text(color="steelblue"))
  3. #ggtitle()与labs(title=) 等价

此处输入图片的描述


  1. > p1 + geom_text(aes(label=weightLb,y=heightIn+0.3),size=3,alpha=0.7,fontface="bold",color="maroon1")

此处输入图片的描述


(1)、图例篇

  1. > p3 <- ggplot(heightweight,aes(ageYear,heightIn,color=sex)) + geom_point()
  2. > p3 + theme(
  3. legend.background=element_rect(fill="grey80",color="red",size=1),
  4. legend.title=element_text(color="blue",face="bold",size=14),
  5. legend.text=element_text(color="red"),
  6. legend.key=element_rect(color="blue",size=0.25)) #图例最里面小正方形的边框颜色。

此处输入图片的描述

(2)、分面篇

  1. > p3 + facet_grid(sex~.) + theme(strip.background=element_rect(fill="navajowhite"),
  2. strip.text.y=element_text(size=14,face="bold",angle=-45))

此处输入图片的描述

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注