2
library(ggplot2)
d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE) + theme(aspect.ratio = 1)

d + facet_wrap(~ color)

Here this produces

enter image description here

What if you wish to have XLABEL under each column centered such as this:

enter image description here

bvowe
  • 3,004
  • 3
  • 16
  • 33
  • 1
    Does the following [ggplot: How to create different x-axis titles with facet_grid](https://stackoverflow.com/questions/49092604/ggplot-how-to-create-different-x-axis-titles-with-facet-grid) help you? – KoenV May 22 '20 at 16:39
  • 1
    @KoenV thanks so much I wasn't able to get that to work on this application maybe because the heights are different – bvowe May 22 '20 at 16:59
  • 1
    [This post](https://stackoverflow.com/questions/50513257/ggplot2-facet-grid-with-distinct-x-axis-labels-using-facet-grid) kind of works, specially if you remove the `if ((i %% 2) == 0)` block and change `if (i < 3)` to `if (i < 5)`. Note that function `grid_arrange_shared_legend` became part of CRAN package `lemon` but the version posted to SO worked better. At least it did with me. – Rui Barradas May 22 '20 at 17:27
  • @Rui Barradas thanks so much maybe do you think you can help provide an example? I still haven't gotten it up and running unfortunately! – bvowe May 22 '20 at 18:43

0 Answers0