整个新系列。目前的几个系列, #R实战 以生信分析为主, #跟着CNS学作图 以复现顶刊Figure
为主,而本系列 #R绘图 则是学习不在文章中但同样很好看的图,致力于给同学们在数据可视化中提供新的思路和方法。
本期图片
![1d85877c29ae7c961f13a4f6bcc768f8.png](https://i-blog.csdnimg.cn/blog_migrate/1b26731f51a9090a4bbb72e694091887.png)
有几个有意思的地方:
圆角柱状图
标题颜色修改
示例数据和代码领取
点赞
、在看
本文,分享至朋友圈集赞20个
并保留30分钟
,截图发至微信mzbj0002
领取。
木舟笔记2022年度VIP可免费领取。
木舟笔记2022年度VIP企划
权益:
2022年度木舟笔记所有推文示例数据及代码(在VIP群里实时更新)。
木舟笔记科研交流群。
半价购买
跟着Cell学作图系列合集
(免费教程+代码领取)|跟着Cell学作图系列合集。
收费:
99¥/人。可添加微信:mzbj0002
转账,或直接在文末打赏。
![4aed54c9ee1e34a471fa5dec00fd8391.png](https://i-blog.csdnimg.cn/blog_migrate/f4f3028a79e172c638ab6f1e284c94bf.png)
绘制
# 安装并加载包
# install.packages("ggchicklet", repos = "https://cinc.rud.is")
library(tidyverse)
library(ggplot2)
library(ggchicklet)
library(prismatic)
library(ggtext)
df = read.csv('df_0610.csv')
# 设置标题及字符颜色
title = "Are they
<span style='color:#FF0000;'>r</span><span style='color:#FFDB00;'>a</span><span style='color:#49FF00;'>i</span><span style='color:#00FF92;'>n</span><span style='color:#0092FF;'>b</span><span style='color:#4900FF;'>o</span><span style='color:#FF00DB;'>w</span>-<span style='color:#FF0000;'>w</span><span style='color:#FFDB00;'>a</span><span style='color:#49FF00;'>s</span><span style='color:#00FF92;'>h</span><span style='color:#0092FF;'>i</span><span style='color:#4900FF;'>n</span><span style='color:#FF00DB;'>g</span> you? "
df %>%
ggplot(aes(x = year, y = sum, fill = fct_rev(comp))) +
geom_chicklet(aes(color = after_scale(clr_darken(fill, 0.5))),
alpha = .75,
show.legend = FALSE) +
geom_point(aes(x = -83, y = 40, fill = comp),
size=4, alpha = .8, shape = 21) +
scale_fill_manual(values = c("black", rev(rainbow(7)), "black")) +
scale_x_continuous(breaks = seq(2012, 2023, 1), limits = c(2012.5, 2022.5)) +
scale_y_continuous(breaks = seq(0, 600000, 100000),
labels = c("0", "100K", "200K", "300K", "400K", "500K", "600K")
) +
labs(
title = title,
x = "",
y = "Dollars donated to anti-LGBTQ politicians"
) +
theme_minimal(base_size=9, base_family="Consolas") +
theme(
plot.title.position = 'plot',
plot.title = element_markdown(face = 'bold', size = 15, hjust = 0),
plot.margin = margin(10, 15, 10, 10),
axis.text = element_text(color = "gray10"),
axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
legend.position = "top",
legend.title = element_blank(),
legend.text = element_text(size = 8)
) +
guides(fill=guide_legend(nrow = 2, byrow = FALSE, reverse = TRUE))
ggsave("rainbow-washing.png", w = 6, h = 6, dpi = 300)
![e159042c66aaa08f3a792f888130813e.png](https://i-blog.csdnimg.cn/blog_migrate/e4ca7620611903548470122580c834a3.png)
参考
https://github.com/neilcuz/tidytuesday/blob/
往期内容
![f72a452dab64ad7d8d9975222d92081c.png](https://i-blog.csdnimg.cn/blog_migrate/3f715479217edfa3a51a9a251d021b07.png)