2
I have a time series record, and I’m having trouble plotting on an appropriate scale. Take this example:
#Gerar sinal v1
v1=sin(seq(from=0, to=3*2*pi, length=11060))
#Gerar sinal v2
v2=sin(seq(from=0, to=5*2*pi, length=11060))
#Gerar série temporal horária entre 06-maio-2016 15h:00min e 10-ago-2017 10h:00min
time_series_total <- seq(from = as.POSIXct("2016-05-06 15:00"),
to = as.POSIXct("2017-08-10 10:00"), by = "hour")
So when I plot:
plot(x = time_series_total, y = v1, type = 'l', col = "red", xlab = "tempo")
lines(x = time_series_total, y = v2, col = 'blue')
legend("topright", legend=c("v1", "v2"),
col=c("red", "blue"), lty=1:1, cex = 1.25, box.lty=0,inset = 0.005)
... The abscissa scale is not legal
What I would like to do is present the scale of the axes with the information of month and year. What is the suggestion?
Thanks, Marcus. I actually have 8 vectors, registered in 11060 hours. Still you find it more interesting to create a data.frame with 11060x8 lines? I will try here and see what I do. Besides, I think I asked about the way to plot, because for now I want to make eight graphs. The best way to do it is not to do it at all?
– Rafael-Pedrollo-de-Paes
Yes, I find it more interesting to create a data frame with 11060*8 lines. This will make your work much easier. On the different graphics, you can do with a
for
or, if you like, add the command+ facet_wrap(~ grupo)
to the code I passed above. See the result obtained and evaluate if it fits your case.– Marcus Nunes
I modified a lot of my question, but I will test this facet_wrap.
– Rafael-Pedrollo-de-Paes
Doing this kind of large edit on the question, which completely changes the original meaning of it, is not recommended here in the OS (see why in this link). I suggest that this issue be undone and given that the two answers present at the time of this comment answered the original question, any of them is voted and accepted. Create a new question with your current question.
– Marcus Nunes
Thank you, Marcus. Actually, William’s response is closer than I’d like. I’m just confirming that. Maybe me including the is in the code is all solved.
– Rafael-Pedrollo-de-Paes