R plotting | bubble scatterplot + fitted curve

5bafb7171265c978378e25ccd516968b.png

week1

The whole new series. In the current series, #RActual Combat is mainly based  on bio-information analysis , #Follow CNSLearn to draw mainly to reproduce the top journals Figure, and this series #Rdrawing is to learn the pictures that are not in the article but also good-looking, dedicated to To provide students with new ideas and methods in data visualization.

Opening picture

880d82da078384561923bc588c607fa8.png

Sample data and code pickup

点赞, 在看this article, share it in the circle of friends , 集赞20个and 保留30分钟send the screenshot to WeChat to mzbj0002receive it.

Canoe Notes 2022 VIP can be obtained for free .

Canoe Notes 2022 VIP Project

rights and interests:

  1. 2022 Canoe Notes **All tweet sample data and codes (updated in real time in the VIP group)**.

    3632b0e9108fdc45f598774bc74bd803.png
  2. Canoe Notes Scientific Research Exchange Group .

  3. Half-price purchase 跟着Cell学作图系列合集(free tutorial + code collection)|Follow Cell to learn to draw a collection of series .

TOLL:

99¥/person . You can add WeChat: mzbj0002transfer money, or give a reward directly at the end of the article.

0918cd83715ab3b59cc6dedbf5b2f921.png
Scan the QR code to add WeChat

draw

rm(list = ls())
library(ggpubr)
library(ggprism)
library(paletteer)

plot_df = read.csv('plot_df.csv')

## 设置主题
rel_size <- 1
my_theme <- theme_prism(border = TRUE, 
                        base_size = 5) +
  theme(strip.text.x = element_text(size = rel(rel_size*2)),
        title = element_text(size = rel(rel_size*2)),
        legend.box.spacing = unit(1, "cm"),
        legend.text = element_text(size = rel(rel_size*1.5)),
        legend.title = element_text(size = rel(rel_size*0.5)),
        axis.text.y = element_text(size = rel(rel_size*2), angle = 0, vjust = 0.2),
        axis.text.x = element_text(size = rel(rel_size*1.6), angle = 45),
        panel.grid = element_line(color = "gray",
                                  size = 0.15,
                                  linetype = 2),
        panel.spacing = unit(1, "lines"),
        plot.caption = element_text(size = rel_size*8)) 


# 绘图
p <- ggplot(plot_df, aes(x = log10(mean_gdp_per_capita), y = mean_access_perc)) + 
  # coord_trans("log10") +
  geom_point(data = plot_df, aes(size = mean_death_perc, fill = continent), pch = 21) +
  geom_smooth(method = "loess") +
  scale_fill_paletteer_d("colorblindr::OkabeIto") +
  ggpubr::stat_cor(method = "spearman", 
                   aes(label = paste(..rr.label.., ..p.label.., sep = "~")), 
                   color = "red", geom = "label", label.x = 3.8, label.y = 5) +
  # facet_wrap(vars(continent),drop = TRUE) +
  scale_y_continuous(breaks = c(0, 25, 50, 75, 100)) + 
  my_theme +
  ggtitle("Access to clean energy is associated with GDP") +
  labs(x = "Log10 of Average GDP per capita",
       y = "Average % access to clean fuels/tech",
       fill = "Continent", 
       size = "Average % Death",
       caption = "Spearman correlation\nAveraged values over years 1990-2019\nData source: OurWorldInData.org")

p
ggsave(plot = p, filename = 'week1.pdf',width = 5,height = 4)

reference

  • https://github.com/nicholas-camarda/tidytuesda

Past content

  1. (Free Tutorial + Code Collection)|Follow Cell to Learn Drawing Series Collection

  2. Q&A | How to draw beautiful illustrations in papers?

  3. Front Immunol reproduction | 1. GEO data download and sva batch correction (PCA visualization)


1f5be1474d7b203c965f388e91d2f98a.png

Guess you like

Origin blog.csdn.net/weixin_45822007/article/details/124373792