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

科研菌
关注

# 坐标轴旋转

ggdotchart(df5, x = "name", y = "mpg",           group = "cyl", color = "cyl",           palette = c('#999999','#E69F00','#56B4E9'),           rotate = TRUE,           sorting = "descending",           ggtheme = theme_bw(),           y.text.col = TRUE )

#设置点的大小:

ggdotchart(df5, x = "name", y = "mpg",           group = "cyl", color = "cyl", size = "cyl",           palette = c('#999999','#E69F00','#56B4E9'),           rotate = TRUE,           sorting = "descending",           ggtheme = theme_bw(),           y.text.col = TRUE )

# 统一设定点大小,添加虚线网格

ggdotchart(df5, x = "name", y = "mpg",           group = "cyl", color = "cyl",           palette = c("#00AFBB", "#E7B800", "#FC4E07"),            sorting = "descending",           rotate = TRUE,           dot.size = 2,           y.text.col = TRUE, # Color y text by groups           ggtheme = theme_pubr() # ggplot2 theme           )+           theme_cleveland() # 添加虚线网格

# 添加标签

ggdotchart(df5, x = "name", y = "mpg", size="cyl",           group = "cyl", color = "cyl", label = "name",           font.label = list(size=10,color="red",face="bold"), # bold表示粗体字           palette = c('#999999','#E69F00','#56B4E9'),           rotate = TRUE,           sorting = "descending",           ggtheme = theme_bw(),           y.text.col = TRUE )

# 添加标签边框,避免重叠

ggdotchart(df5, x = "name", y = "mpg", size="cyl", repel = T,           group = "cyl", color = "cyl",            label = "name", label.rectangle = T,           font.label = list(size=10,color="red",face="bold"),           palette = c('#999999','#E69F00','#56B4E9'),           rotate = TRUE,           sorting = "descending",           ggtheme = theme_bw(),           y.text.col = TRUE )

声明: 本文由入驻OFweek维科号的作者撰写,观点仅代表作者本人,不代表OFweek立场。如有侵权或其他问题,请联系举报。
侵权投诉

下载OFweek,一手掌握高科技全行业资讯

还不是OFweek会员,马上注册
打开app,查看更多精彩资讯 >
  • 长按识别二维码
  • 进入OFweek阅读全文
长按图片进行保存