0

data looks like the following sample

|Species| |logSDM| |UseCategories| | X | | 3.14 | |AnimalFood| |Y | | 4.30 | |Medicines| |Z | |9.3 | | Materials| |L | |2.1 | |HumanFood| |X | |1.1 | |Medicine| |F | |3.5 | |Fuels|

the UseCategories variable have 10 categories. I am getting a plot where I can not differentiate among different categories

ggplot(data=final, aes(x=logSDM, fill=UseCategories)) +
 geom_density(adjust=1) +
 theme_ipsum() +
 facet_wrap(~UseCategories) +
 theme([enter image description here][1]
   legend.position="none",
   panel.spacing = unit(0.1, "lines"),
   axis.ticks.x=element_blank()
 )        

The plot I got:

[the plots are apparently the same. It is difficult to differentiate the data from the plots]

Fahmida
  • 1
  • 2
  • 2
    Fahmida, welcome to SO. You will find many friends here, if you provide a so-called reproducible/representative example. If you provide 10-20 lines of your data set `final`, we have an idea about how your data looks like. Check `dput()` or `head()` for this. The code fragment you provided is garbled, e.g. it includes partly the reference to the pic you wanted to append. ... OK. From a code perspective you assign the fill colour and your facets to `UseCategoies`. Check whether the `facet_wrap( . ~ UseCategories)` helps to break out the different groups you want to have. – Ray May 25 '21 at 17:45
  • @Ray, I am new here and really confused about how to add my sample data. – Fahmida May 27 '21 at 11:04
  • no prob. If the above does not ring a bell, please read up on MRE https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. The other option is you "translate" your problem to a built-in dataset like `iris` or `mtcars`. This allows to reproduce your problem/question, and work with you through your struggles. Adding a plot helps to show what your text is referring to. The built in "add your plot"/browse should get you there. – Ray May 28 '21 at 17:10

0 Answers0