1

No code for this I am sorry but I am simply trying to get started with a graph type in R with ggplot2 that I am trying to make, which should look like the following (not sure how it's made, this is a screenshot i took):

enter image description here should I simply use geom_density + facet_wrap? Or does anybody know of a better way to achieve coding up a graph type like this?

Thanks in advance!

zx8754
  • 52,746
  • 12
  • 114
  • 209
Canovice
  • 9,012
  • 22
  • 93
  • 211
  • 2
    The article is [here](https://www.datasciencecentral.com/profiles/blogs/visualizing-the-game-style-and-shooting-performance-among) and the code is [here](https://github.com/nycdatasci/bootcamp007_project/tree/master/Project1-ExploreVis/Xinyuan_Wu) – Ronak Shah Oct 09 '18 at 07:58
  • wow great link - appreciate the share – Canovice Oct 09 '18 at 07:59
  • 1
    Look at the `ggridges` package. – Axeman Oct 09 '18 at 08:29

1 Answers1

2

I would use facet_grid instead of facet_wrap to achieve this, but that is the easiest method in ggplot2

Here's a working example:

diamonds %>% 
   filter(cut %in% c('Ideal','Premium','Very Good')) %>% 
   ggplot(aes(carat)) + 
   geom_density() + 
   facet_grid(cut ~ .)

Should give this result (as of ggplot 3.3.0):

enter image description here

CoderGuy123
  • 6,219
  • 5
  • 59
  • 89
Randall Helms
  • 849
  • 5
  • 15