2

I have a time series and I have reduced this serie with a transformation. For example

The original time serie:

T=(12,13,14,20,65,78,85,35)

and transformed one is:

T'=(17.22009  27.96722 111.16376  71.33732)

and now I want to have such a diagram, in its x-axis I have 8 values but for each 2 values one value from T' . I can do sme thing like this in R: enter image description here

but in the second Plot I want to extend the the diagram on 8 values too

Kaja
  • 2,962
  • 18
  • 63
  • 99
  • Can you please add the commands you use for drawing the plots? Btw `T'` is not a valid variable name in R, since `'` marks the start/end of a string. – Backlin Oct 29 '13 at 12:58
  • Thank you @AndreSilva, actually I want to do this job with more than 1000 values, and I think this way is not perfect – Kaja Oct 29 '13 at 13:05
  • @Backlin what I have here wrote is not a R code, it is only an example – Kaja Oct 29 '13 at 13:05
  • 1
    Yes I understood, but wanted Kaja to add it anyway. I might be obnoxious now, but it's common decency (in lack of better words) to provide potential answerers with a [runnable reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to start working from. – Backlin Oct 29 '13 at 13:12
  • A big problems is that you're just using the index for x-values. If this is really time series data then these values should be matched to times. If those were your x-axis that would be the correct solution, and you might not even have a problem at all. As your question is formulated one can only guess as to how this should really be plotted. – John Oct 29 '13 at 13:47

1 Answers1

2

Assuming T' is called Tc in R you fix the lower one by

plot(0:length(Tc)*2, c(Tc, tail(Tc,1)), type="s")

The additional element added by tail is needed for drawing the last segment, from 6 to 8.

enter image description here

Update

If you just want to stretch the second plot to go between 1 and 8, you can do

plot(seq(1, 2*length(Tc), length.out=length(Tc)+1), c(Tc, tail(Tc,1)), type="s")

However, I take it that each value of the second plot corresponds to two values of the upper plot, so perhaps the best way to visualize it then would be

barplot(Tc, width=2, space=0)
lines(seq(Tb)-.5, Tb, type="b", lwd=2)

enter image description here

Backlin
  • 14,612
  • 2
  • 49
  • 81
  • thank you so much, I think it is my answer, but this diagram begins with `0` if I want to begin with `1` what should I do? I have changed `plot(0:length(Tc)*2...` to `plot(1:length(Tc)*2...` but I get an error – Kaja Oct 29 '13 at 13:19