1

Edit to this question:

This is a very simple question and I apologise for having over-complicated it. Below is what I should have asked. Any advice would be a big help, please!

  • I have a panel of 2 x 4 boxplots showing the chemical concentrations in samples from two site-types, A and B.
  • Since I have a total of eight boxplots (created using the cowplot function), I don't want 'site type' underneath each of all eight plots.
  • I just want to have 'site type' on the x-axis of the bottom four plots. How is this done please?

Thank you very much in advance for advice!

Cheers

Mike

I apologise for not producing an example. I can produce one if necessary but I think you'll agree it's quite a basic question

Mike_989
  • 23
  • 7
  • 1
    To paste it's CTRL+V, leave blank lines between the text and the code (before and after the code), then select the code and press CTRL+K. – Rui Barradas May 30 '19 at 14:22
  • 1
    It would be great if you could share a *small* and *reproducible* example. Perhaps 2 plots is enough to illustrate the problem, not 8? And you could either use built-in data (like `iris` or `mtcars`) or share a little bit of data with (`dput()` so it is copy/pasetable) so we can run your code. Lots more tips and and details on reproducibility [here](https://stackoverflow.com/q/5963269/903061). – Gregor Thomas May 30 '19 at 14:47
  • Ok Gregor. I will see what I can do. – Mike_989 May 30 '19 at 14:50
  • See the *minimal* part of [mcve]. You can pare this task down to just its essentials: we don't need to recreate all 8 plots when you could probably recreate the issue with just a few. We also most likely don't need to worry about the majority of your theme elements, which take up a considerable amount of space. Also, why are you setting xlabs but then making the axis blank? – camille May 30 '19 at 15:32
  • Hi Camille - yep - points taken. Will re-do this if its more convenient! – Mike_989 May 30 '19 at 16:00

1 Answers1

0

Problem solved! I used the advice here: https://cran.r-project.org/web/packages/cowplot/vignettes/plot_annotations.html Specifically: p1 <- ggplot(mtcars, aes(mpg, disp)) + geom_line(colour = "blue") + background_grid(minor='none') p1 p2 <- add_sub(p1, "This is an annotation.\nAnnotations can span multiple lines.") ggdraw(p2) Cheers M

Mike_989
  • 23
  • 7