I am trying to plot 3 graphs with the same axes in the same figure. The first of which, the "y-values" are in percentages. The other 2 are in decimal points, and I am trying to convert to percentage.
I initially worked with the following code:
plot(timeSP500[(N+1):nSP500],sigmaSP500[(N+1):nSP500],type='l', ylim=c(0, 0.05))
par(new=TRUE)
plot(timeSP500[(N+1):nSP500],sqrt(EWSP500[(N+1):(nSP500)]),type='l')
par(new=TRUE)
plot(timeSP500[(N+1):nSP500],sqrt(UVdevSP500[(N+1):(nSP500)]),type='l')
There was no issue with the output, BUT it was not what I wanted because for the second and third graphs, they are in decimal places and not percentages. So I added in the percent function.
plot(timeSP500[(N+1):nSP500],sigmaSP500[(N+1):nSP500],type='l', ylim=c(0, 0.05))
par(new=TRUE)
plot(timeSP500[(N+1):nSP500],percent(sqrt(EWSP500[(N+1):(nSP500)])),type='l')
par(new=TRUE)
plot(timeSP500[(N+1):nSP500],percent(sqrt(UVdevSP500[(N+1):(nSP500)])),type='l')
With this I get the error
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
Which is very weird, because if say I output percent(sqrt(EWSP500[(N+1):(nSP500)]))
only, there seems to be no error in the output, but I cannot output it in the graph as above.