Rich Shepard
2021-Nov-10 19:44 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
I have the code to create ggplot2 boxplots using two attributes (e.g., chemical concentration and month) from the same tibble. Is there an example from which I can learn how to make boxplots from different tibbles/dataframes (e.g., chemical concentrations and monitoring location)? TIA, Rich
Rich Shepard
2021-Nov-10 20:16 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
On Wed, 10 Nov 2021, Rich Shepard wrote:> I have the code to create ggplot2 boxplots using two attributes (e.g., > chemical concentration and month) from the same tibble. Is there an > example from which I can learn how to make boxplots from different > tibbles/dataframes (e.g., chemical concentrations and monitoring > location)?To clarify: I'd like to produce a plot such as Naomi Robbins presents in figure 4.11 of her book, "Creating More Effective Graphics." In my case I want to present river boxplots of discharges over each monitoring site's period of record as a vertical stack of horizontal boxplots. The northern-most site actually has negative discharges twice a day as it's tidally influenced at about 125 River Miles from the ocean and the incoming tides push the water upriver. Rich
Rich Shepard
2021-Nov-11 15:50 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes [RESOLVED]
On Wed, 10 Nov 2021, Rich Shepard wrote:> I have the code to create ggplot2 boxplots using two attributes (e.g., > chemical concentration and month) from the same tibble. Is there an > example from which I can learn how to make boxplots from different > tibbles/dataframes (e.g., chemical concentrations and monitoring > location)?I think that I've found the solution (haven't yet tested it, though): <https://statisticsglobe.com/combine-two-ggplot2-plots-from-different-data-frames-in-r>. It's from Statistical Globe and uses this code: ggp <- ggplot(NULL, aes(x, y)) + # Draw ggplot2 plot based on two data frames geom_point(data = data1, col = "red") + geom_line(data = data2, col = "blue") ggp # Draw plot More when I try it with four boxplots. Rich
John Dougherty
2021-Nov-12 00:52 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
On Wed, 10 Nov 2021 11:44:07 -0800 (PST) Rich Shepard <rshepard at appl-ecosys.com> wrote:> I have the code to create ggplot2 boxplots using two attributes (e.g., > chemical concentration and month) from the same tibble. Is there an > example from which I can learn how to make boxplots from different > tibbles/dataframes (e.g., chemical concentrations and monitoring > location)? > > TIA, > > Rich >You should probably glance at the R Graphics Cookbook. That was my gateway to ggplot. I believe ggplot is a part of the tidyverse so there should good information. JWDougherty