侵权投诉
搜索
更多>> 热门搜索:
订阅
纠错
加入自媒体

ggpubr包绘图技巧分享:饼图、棒棒糖图、Cleveland 点图

2020-12-29 10:11
科研菌
关注

ggtheme

设置画图主题,默认是theme_pubr()。

ggplot2 official themes: theme_gray(), theme_bw(), theme_minimal(), theme_classic(), theme_void()


棒棒糖图

# 棒棒图可以代替条形图展示数据,用到的数据是df5(柱状图多单调,改用棒棒糖图添加多样性哦~)ggdotchart(df5, x="name", y="mpg", color = "cyl",           palette = c("#00AFBB", "#E7B800", "#FC4E07"),           sorting = "ascending",           add = "segments", ggtheme = theme_pubr())

#设置分组:ggdotchart(df5, x="name", y="mpg", color = "cyl",group = "cyl",               palette = c("#00AFBB", "#E7B800", "#FC4E07"),                      sorting = "ascending",                      add = "segments", ggtheme = theme_pubr())

# 坐标轴变换ggdotchart(df5, x="name", y="mpg", color = "cyl",           palette = c("#00AFBB", "#E7B800", "#FC4E07"),           sorting = "descending", add = "segments", rotate = TRUE,           group = "cyl",           ggtheme = theme_pubr())

# dot.size = 6调整糖的大小,label = round添加糖心中的数值,font.label进一步设置字体样式ggdotchart(df5, x="name", y="mpg", color = "cyl",          palette = c("#00AFBB", "#E7B800", "#FC4E07"),          sorting = "descending", add = "segments", rotate = TRUE,          group = "cyl", dot.size = 6,          label = round(df2$mpg), # round函数表示四舍五入          font.label = list(color="white",size=9, vjust=0.5), # vjust 调节 label 和糖心的相对位置          ggtheme = theme_pubr())

ggdotchart 函数:用法:ggdotchart(data, x, y, group = NULL, combine = FALSE, color = "black",           palette = NULL, shape = 19, size = NULL, dot.size = size,           sorting = c("ascending", "descending"), add = c("none", "segment"),           add.params = list(), x.text.col = TRUE, rotate = FALSE, title = NULL,           xlab = NULL, ylab = NULL, facet.by = NULL, panel.labs = NULL,           short.panel.labs = TRUE, select = NULL, remove = NULL, order = NULL,           label = NULL, font.label = list(size = 11, color = "black"),           label.select = NULL, repel = FALSE, label.rectangle = FALSE,           ggtheme = theme_pubr(), ...)           theme_cleveland(rotate = TRUE)

参数:

data

所需的数据框 dataframe

x,y

进行作图所需的数据

group

分组变量(x轴方向上)

combine

对于多个变量的数据是否分面

<上一页  1  2  3  4  下一页>  
声明: 本文由入驻维科号的作者撰写,观点仅代表作者本人,不代表OFweek立场。如有侵权或其他问题,请联系举报。

发表评论

0条评论,0人参与

请输入评论内容...

请输入评论/评论长度6~500个字

您提交的评论过于频繁,请输入验证码继续

暂无评论

暂无评论

工控 猎头职位 更多
文章纠错
x
*文字标题:
*纠错内容:
联系邮箱:
*验 证 码:

粤公网安备 44030502002758号