Entering edit mode
2.0 years ago
Camila MartÃnez
▴
40
Hello, I don't know how to make a plot and indicate the limits for the y axis. I tried with:
ggplot() +
geom_step(data = Pcal.msmc2, aes(x = time_scaled, y = Ne_scaled), color = "red") +
ggtitle(my_title2, subtitle=my_subtitle2) +
xlab("Years ago") +
ylab("Number of individuals (Ne)") +
annotation_logticks(sides = "bl") +
scale_x_continuous(trans='log10', breaks=trans_breaks('log10', function(x) 10^x),
labels=trans_format('log10', math_format(10^.x))) +
scale_y_continuous(trans='log10', breaks=trans_breaks('log10', function(x) 10^x),
labels=trans_format('log10', math_format(10^.x))) +
expand_limits(x = c(100, 100000), y = c(0,1000))
But it didn't work, I got this image:
I want the plot only to show from 0 to 10000 on the y axis. How can I do that?
You can't include 0 on a log scale: log10(0) = -infinity (or rather, the limit as you approach 0 is -infinity... you get the idea).
Someone else will probably have a better answer about what you should do, though... use a broken y axis and special handling for zeros? use two panels? rethink using a log scale at all?