问题
Dear stackoverflow community,
I'm quite new in R and this is my first stackoverflow entry so please show mercy with me if it's not the perfect questioning.
I'm calculating standardized precipitation index (SPI) with the package "SPEI" for a time series of a climate station with 20 years of monthly precipitation data. I have done this for the timescale of 1 and 12 month like this:
spi1 <- spi(SPI_Anu_input_ts[,'PRCP_Anu'], 1)
spi12 <- spi(SPI_Anu_input_ts[,'PRCP_Anu'], 12)
The output of SPI is not a matrix or a dataframe, it's a list. Inside this list under the entry fitted you find a timeseries with the wanted and calculated index values.
To plot these index values you don't have to enter x & y like usual:
plot(x, y, ...)
You can just use the complete list:
par(mfcol=c(2,1))
plot(spi1, 'Anuradhapura, SPI-1')
plot(spi12, 'Anuradhapura, SPI-12')
Then it looks like this:
Plot SPI1 & SPI12
Part of SPI calculation is that the amount of time scale is the first month for the first index value. The precipitation data is starting in Jan 1990. So the indices for SPI1 start in january but for SPI12 start in december (first 11 month are NA).
As you can see in the graphic both x and y axes are shifted. Neither
xlim=as.Date(c("1990-01-01","2017-09-01"))
nor any axes limitation like
ylim=c(-2.5,2.5)
is working to have the same value range in both graphics.
Do anyone know how to solve that?
来源:https://stackoverflow.com/questions/52311811/r-project-how-to-limit-axes-in-spi-plot-ylim-xlim-dont-work