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
Bert Gunter
2021-Nov-10 21:09 UTC
[R] ggplot2: multiple box plots, different tibbles/dataframes
As always, online search (on "ggplot2 help") seemed to bring up useful resources. I suggest you look here (suggested tutorials and resources are farther down the page): https://ggplot2.tidyverse.org/ Bert Gunter On Wed, Nov 10, 2021 at 12:16 PM Rich Shepard <rshepard at appl-ecosys.com> wrote:> > 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 > > ______________________________________________ > 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.
Richard M. Heiberger
2021-Nov-10 21:40 UTC
[R] [External] ggplot2: multiple box plots, different tibbles/dataframes
I don't understand your question. It looks like the example in ?lattice::panel.bwplot does exactly what you want (modulo using ggplot instead of lattice). Therefore it looks like creating a single column of y from the y in each data.frame, and also a single column of x from the x in each data.frame should be enough. Here is an even simpler example y <- rnorm(20) x <- rep(1:2, each=10) library(lattice) bwplot(x ~ y, horizontal=TRUE)> On Nov 10, 2021, at 15:16, Rich Shepard <rshepard at appl-ecosys.com> wrote: > > 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 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=04%7C01%7Crmh%40temple.edu%7C4cd107806f544ff7ef4308d9a4870974%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637721722866567947%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=t1sBLzlyyxPEq2%2F54BoDdmP1qkfLb9ABosQ0mI6rEjA%3D&reserved=0 > PLEASE do read the posting guide https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=04%7C01%7Crmh%40temple.edu%7C4cd107806f544ff7ef4308d9a4870974%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637721722866567947%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=nu%2Bjxppbmi4UtEngfs3DrJXQWcyxUVNSoGYgnEDwi%2F8%3D&reserved=0 > and provide commented, minimal, self-contained, reproducible code.