3
votes

I am trying to plot two time series on the same x-axis (but different y-axis). However I am having issues with the y-axis labels overlapping.

The code to generate the issue is below.

set.seed(123)
library(zoo) 
plot(as.zoo(cbind(rnorm(1000,.1,50),runif(1000,0,100))))

You should see the lowest y-tick value for the first plot overlaps with the top y-tick value on the second plot. How would you go about fixing that?

1

1 Answers

2
votes

What about using las=1, cex.axis=.7 and some ylim modification? See ?par for a detailed explanation of what las and cex.axis do

set.seed(123)
library(zoo) 
plot(as.zoo(cbind(rnorm(1000,.1,50),runif(1000,0,100))), 
 cex.axis=.7, las=1, ylim=list(c(-160,160), c(0,100)))

which produces:

enter image description here

Another solution would be using yax.flip=1

set.seed(123)
library(zoo) 
plot(as.zoo(cbind(rnorm(1000,.1,50),runif(1000,0,100))),  yax.flip=1)

enter image description here