I need to create 16 bar plots in one figure (facet or split screen)for scientific paper from a data.frame with 17 numeric columns, and use the argument split to separate the bars by Month. I have a large data.frame for 16 evaporation methods with average monthly values. I try to do it by faceting and split screen but I could not.I have attached the image of data.I hope find solution.Best regards
Asked
Active
Viewed 50 times
1 Answers
0
Have a look at how to reshape your data from wide to long format. Then you can use 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)

lukeA
- 53,097
- 5
- 97
- 100