如何使用多列和参数“split”创建一个条形图

How to create one bar plots using multiple columns and argument “split”

我需要从具有 17 个数字列的 data.frame 为科学论文创建 16 bar plots in one figure(分屏或分屏),并使用参数 split 按月份分隔条形。我有一个很大的 data.frame 用于 16 种具有月平均值的蒸发方法。我尝试通过分面和分屏来做到这一点,但我可以 not.I 附上 data.I 的图像希望找到 solution.Best 问候

看看如何将数据从宽格式重塑为长格式。然后你可以使用ggplot:

# create sample data
df <-  cbind(Month = 1:12, as.data.frame(replicate(16, runif(12))))

# reshape it from wide to long format
df <- reshape(df, idvar = 1, varying = list(-1), times = names(df)[-1], direction = "long", sep = "", timevar = "key", v.names = "value")

# Facetted bar plot
library(ggplot2)
ggplot(df, aes(x = Month, y = value)) + 
  geom_bar(stat = "identity") + 
  facet_wrap(~key)