ggpubr包绘图技巧分享:饼图、棒棒糖图、Cleveland 点图
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
对于多个变量的数据是否分面
图片新闻
最新活动更多
-
技术指南立即下载>> 电动汽车功率半导体技术趋势变化带来的挑战及解决方案
-
2月28日火热报名中>> 【免费试用】东集技术年终福利——免费试用活动
-
4日10日立即报名>> OFweek 2025(第十四届)中国机器人产业大会
-
限时免费下载立即下载 >>> 2024“机器人+”行业应用创新发展蓝皮书
-
7.30-8.1火热报名中>> 全数会2025(第六届)机器人及智能工厂展
-
7月30-31日报名参会>>> 全数会2025中国激光产业高质量发展峰会
推荐专题
发表评论
请输入评论内容...
请输入评论/评论长度6~500个字
暂无评论
暂无评论