接触到了一个新包 ggalt

Description: A package containing additional geoms, coords, stats, scale and fonts for ggplot2 2.0+。用help(package="ggalt")命令查看帮助文档中的userguide,发现了一些很有意思的图表,记录重复代码

第一幅 Dumbbell(哑铃) charts

(本想重复ggalt帮助文档中的代码,但遇到了以前没有遇到过的错误

Lollipop charts_帮助文档

很奇怪,运行geom_dumbbell()就会出现这个错误)

第二幅 Lollipop(棒棒糖) charts

知识点:

theme(panel.grid.major.y=element_blank())去掉了网格中的横线

theme(panel.grid.minor.x=element_blank())去掉了网格中的竖线;major和minor一个是大网格的线一个是小网格的线

theme(axis.line.y=element_line(color="red",size=0.15))将y轴改成了红色

theme(axis.text.y=element_text(margin=margin(r=0,l=0)))更改了坐标轴与文字间的距离

theme(plot.margin=unit(rep(30,4),"pt"))更改了绘图边界,unit()函数的运行结果

Lollipop charts_其他_02


Lollipop charts_数据_03
完整代码
Lollipop charts_其他_04
结果图

数据Lollipop_data.RData