R语言点绘图,并且这些点是从大到小降序排序的
libary(plyr) # Needed for desc()
library(gcookbook) # For the data set
tophit <- tophitters2001[1:25, ] # Take the top 25 from the tophitters data set
ggplot(tophit, aes(x=avg, y=name)) + geom_point()
ggplot(tophit, aes(x=avg, y=reorder(name, avg))) +
geom_point(size=3) + # Use a larger dot
theme_bw() +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="dashed"))

linetype改成solid效果:
ggplot(tophit, aes(x=avg, y=reorder(name, avg))) +
geom_point(size=3) + # Use a larger dot
theme_bw() +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="grey60", linetype="solid"))

修改后:取前30个样本,size改为6,颜色改为绿色
libary(plyr) # Needed for desc()
library(gcookbook) # For the data set
tophit <- tophitters2001[1:30, ] # Take the top 30 from the tophitters data set
ggplot(tophit, aes(x=avg, y=name)) + geom_point()
ggplot(tophit, aes(x=avg, y=reorder(name, avg))) +
geom_point(size=6) + # Use a larger dot
theme_bw() +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.y = element_line(colour="green", linetype="solid"))

size设置为4,angle设置成90度,hjust设置成TRUE,线型linetype设置成solid
libary(plyr) # Needed for desc()
library(gcookbook) # For the data set
tophit <- tophitters2001[1:30, ] # Take the top 30 from the tophitters data set
ggplot(tophit, aes(x=reorder(name, avg), y=avg)) +
geom_point(size=4) + # Use a larger dot
theme_bw() +
theme(axis.text.x = element_text(angle=90, hjust=TRUE),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(colour="grey60", linetype="solid"))

size设置为3,angle设置成60度,hjust设置成1
libary(plyr) # Needed for desc()
library(gcookbook) # For the data set
tophit <- tophitters2001[1:30, ] # Take the top 30 from the tophitters data set
ggplot(tophit, aes(x=reorder(name, avg), y=avg)) +
geom_point(size=3) + # Use a larger dot
theme_bw() +
theme(axis.text.x = element_text(angle=60, hjust=1),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(colour="black", linetype="solid"))

参考文献:Practical Receipes for Visualizing Data----R Graphics Cookbook —Winston Chang O’REILLY
百度文库—颜色大全:含中英文对照及色值
- 点赞
- 收藏
- 关注作者
评论(0)