Boxplotting with measured variables on X-axis

I have another data set on underground water mineral content measured along a river basin at three locations: Upper, Middle and Lower. The measured values are Hydrocarbonate, Chloride, Sulphate content and EC. I intended to upload the data but unfortunately, the Excel file formats are not accepted. I want to plot boxplots like the ones shown in the attached image in R using ggplot2. Would anyone help how I can do it? The measure variable should be o


n the X-axis and the values on Y-axis as shown in the image. All boxplots have to be in one graph with one Y-axis.
Thanks in advance for your help

Use facets to divide the data:
Lay out panels in a grid — facet_grid • ggplot2

You can change the theme settings to make the result look closer to the example you provided.

face_wrap, I know it does however, all the 4 element, each should be on the x-axis with three boxplots for each location and for all the four measured variables should share a single y-axis as shown in the picture.

That's precisely what facet_grid() does. facet_wrap() also does the same if the no. of rows is set to one.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.