整个新系列。目前的几个系列, 「#R实战」 以「生信分析」为主, 「#跟着CNS学作图」 以「复现顶刊」Figure
为主,而本系列 「#R绘图」 则是学习不在文章中但同样很好看的图,致力于给同学们在数据可视化中提供新的思路和方法。
本系列往期文章
本期图片
示例数据和代码领取
点赞
、在看
本文,分享至朋友圈集赞20个
并保留30分钟
,截图发至微信mzbj0002
领取。
「木舟笔记2022年度VIP可免费领取」。
木舟笔记2022年度VIP企划
「权益:」
「2022」年度木舟笔记所有推文示例数据及代码(「在VIP群里实时更新」)。
data+code 木舟笔记「科研交流群」。
「半价」购买
跟着Cell学作图系列合集
(免费教程+代码领取)|跟着Cell学作图系列合集。
「收费:」
「99¥/人」。可添加微信:mzbj0002
转账,或直接在文末打赏。
绘制
rm(list = ls())
library(ggthemes)
library(ggplot2)
by_names <- read.csv('by_names.csv')
head(by_names,5)
p
p <-by_names%>%
ggplot(aes(x=avg_rating,y=fct_reorder(word,-avg_rating)))+
geom_col(aes(fill=names), position = position_fill(),color="black")+
ggthemes::scale_fill_tableau()+
guides(fill=guide_legend(nrow = 1,reverse = T,keywidth = 0))+
labs(fill="")+
ggthemes::theme_fivethirtyeight()+
theme(text=element_text(color="grey90"),
plot.title = element_text(size=22),
legend.position = "top",
legend.background = element_rect(fill="black",color="black"),
legend.text = element_text(size=12),
strip.background = element_blank(),
axis.text.y = element_text(size=12),
panel.grid = element_line(size=3),
plot.background = element_rect(fill="black",color="black"),
panel.background = element_rect(fill="black",color="black"))
p
ggsave("stack_bar.png",
dpi=320,
height = 7,
width = 9)
参考
https://github.com/Fgazzelloni/TidyTuesday/blob/main/data/2022/w33_psychometrics/w33_psychometrics.Rmd