0

I want to create a group of graphs using RStudio and want the scales to be consistent between all graphs. The graphs were created with the ggplot2 package and the geom_dotplot function. For the x-axis, the values were converted to factors. In the first graph, levels 0-6 are available, but in the second graph (subpopulation of the first group), only groups 1-6 occured in the dataframe (thus, level "0" is not shown). As a result, the scaling of the X-axis of both graphs is not uniform.

I have already tried different approaches to force RStudio to show all levels. Among others I tried the following:

scale_x_discrete(drop=FALSE, limits=c("0", "6"), breaks=c("0", "1", "2", "3", "4", "5", "6"))

However, it didn't work...

Do you have an idea how to solve this issue?

Thanks in advance!

jwvh
  • 50,871
  • 7
  • 38
  • 64
mave13
  • 1
  • 1
    Can you explain or show what didn't work? Also try to provide a [reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – David J. Bosak Feb 15 '21 at 23:53
  • It would be easier to help if you create a small reproducible example along with expected output. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). – Ronak Shah Feb 16 '21 at 09:23
  • Thank you for the support offered! I have again spent several hours to find the error. In the end, a "+" was missing at the end of the previous command, which is why the above term was not included. Now it works perfectly (so the term was correct in itself). – mave13 Feb 16 '21 at 20:24

1 Answers1

0

Thank you for the support offered! I have again spent several hours to find the error. In the end, a "+" was missing at the end of the previous command, which is why the above term was not included. Now it works perfectly (so the term was correct in itself).

mave13
  • 1