0

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.

lmo
  • 37,904
  • 9
  • 56
  • 69
J. Kang
  • 73
  • 5
  • Please try to provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), perhaps by using `dput` or some simulated data. – Johan Larsson Mar 11 '17 at 14:15
  • And when you are using functions from a package, it is helpful to indicate which packages were used, e.g. `library(memisc)` – G5W Mar 11 '17 at 16:16

0 Answers0