Bill Dunlap
2021-Nov-11 15:39 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
I googled for "ggplot2 boxplots by group" and the first hit was https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html which displays lots of variants along with the code to produce them. It has links to ungrouped boxplots and shows how violin plots can better display your data. -Bill On Thu, Nov 11, 2021 at 5:50 AM Rich Shepard <rshepard at appl-ecosys.com> wrote:> On Wed, 10 Nov 2021, Avi Gross via R-help wrote: > > > I think many here may not quite have enough info to help you. > > Avi, > > Actually, you've reflected my thinking. > > > But the subject of multiple plots has come up. There are a slew of ways, > > especially in the ggplot paradigm, to make multiple smaller plots into a > > larger display showing them in some number of rows and columns, or other > > ways. Some methods use facet_wrap() or facet_grid() type functionality > that > > let you plot multiple subdivisions of the data independently. These > though > > generally have to be in some way related. > > My experience with facets (which I belive are like latice's conditioned > trellis plots has each plot in a separate frame in a row, column, or > matrix.) That won't communicate what I want viewers to see as well as would > having all in a single frame. > > My data represent hydrologic and geochemical conditions at four locations > along the mainstem of a river. While the period of record for each > monitoring gauge is different, I want to illustrate how highly variable > conditions are at each location. The major factor of interest is discharge, > the volume of water passing a river cross section at the gauge location in > cubic feet per second. I have created boxplots for each site representing > the distribution of discharge for the entire data set and I'd like to place > each of the four horizontal boxplots stacked vertically with the > southern-most at the bottom and the northern-most at the top (the river > flows north). > > > Yet others let you make many independent graphs and save them and later > > recombine them in packages like cowplot. > > I discovered cowplot yesterday but haven't yet read the PDF or vignette. > > > So, although it may also be possible to do whatever it is you want > within a > > single plot, it may also make sense to do it as loosely described above. > > While I certainly may be wrong, I believe that seeing all four boxplots in > the same frame makes the differences in distribution most clear. > > Thanks, > > Rich > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Rich Shepard
2021-Nov-11 15:41 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
On Thu, 11 Nov 2021, Bill Dunlap wrote:> I googled for "ggplot2 boxplots by group" and the first hit was > https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html > which displays lots of variants along with the code to produce them. It > has links to ungrouped boxplots and shows how violin plots can better > display your data.Bill, I searched for 'ggplot2 multiple boxplots' so I missed that one. Thanks very much, Rich
Rich Shepard
2021-Nov-11 15:46 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
On Thu, 11 Nov 2021, Bill Dunlap wrote:> I googled for "ggplot2 boxplots by group" and the first hit was > https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html > which displays lots of variants along with the code to produce them. It > has links to ungrouped boxplots and shows how violin plots can better > display your data.Bill, As I thought, all the returned pages use multiple groups within the same dataframe. I'm still looking to learn how to pass multiple dataframes to one ggplot() function, each with its own aesthetics. Regards, Rich