【问题标题】:How to produce a similar plot? [R]如何制作类似的情节? [R]
【发布时间】:2021-03-10 19:46:08
【问题描述】:

本文的作者 (https://www.sciencedirect.com/science/article/pii/S0092867415006418) 在他们的补充文件中提到这些是在 Matlab 中生成的。由于缺乏熟练度、学习时间和许可证,我试图在 R 中复制下图(论文的图 2,特别是左侧的图 2A):

有什么建议吗?这个情节更普遍地叫什么?

谢谢!

【问题讨论】:

  • 您有任何数据可以分享以便更轻松地帮助您吗?
  • 这不是提示所建议的我的数据。
  • 在这种情况下,我还没有投反对票。但是,鉴于与您相似的虚假数据,为您的问题提供工作代码会更容易。为了帮助您,我们必须发明一些数据,希望它们可能与您的相似,并创建一些基于某些可能错误的数据的代码。
  • 如果问题只是“它怎么叫这个情节?”,这个问题不符合 SO 标准,因为它与代码无关,可以关闭。数据有助于您创建情节。

标签: r ggplot2 data-visualization


【解决方案1】:

对我来说,这看起来像是一个经典的点情节!您可以使用 ggplot 在 R 中重现这种情节:

# Fake dataframe with xy coordinates, type of data (for the coloring), pvalue (for size), and different panel
df <- data.frame(
  x = rep(1:20, 10),
  y = rnorm(200, mean = 0, sd = 2),
  type = rep(rep(LETTERS[1:5], each = 4), 10),
  pvalue = sample(0:50, size = 200, replace = T)/1000,
  panel = sample(rep(paste0("panel", 1:4), each = 50)), 200, replace = F)


# plot
library(ggplot2)
ggplot(df, aes(x, y*x , color = type, size = pvalue)) + geom_hline(yintercept = 0) + geom_point() + facet_wrap(~panel, ncol = 2)

ggsave("demo.png")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-18
    • 2014-10-11
    • 2021-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多