I want to start from 0 origin but unfortunately I can not fix the problem. Any solution? I have already tried expand_limits
and xlim
but they did not work.
Asked
Active
Viewed 168 times
0
-
1Possible duplicate of [Force the origin to start at 0 in ggplot2 (R)](https://stackoverflow.com/questions/13701347/force-the-origin-to-start-at-0-in-ggplot2-r) – aosmith Aug 25 '17 at 14:45
-
Can you include the code you used & elaborate on your question? Going purely on the chart you posted, both x & y axis include 0 in their respective ranges. – Z.Lin Aug 26 '17 at 13:00
1 Answers
0
I think you need to use scale_x_continuous
.
If you have plotted your graph and named it as so.graph
for this example, then you'd need to add:
so.graph + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0))
.
You'll also need to add in some limits so the graph doesn't cut off any points - without knowing your values I can't suggest appropriate points, but this would look like:
so.graph + scale_x_continuous(expand = c(0, 0), limits = c(0,20)) + scale_y_continuous(expand = c(0, 0), limits = c(0,20))
Hope this helps!

Sam Hillman
- 84
- 5