Raghuraman Ramachandran
2015-Apr-07 16:30 UTC
[R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot
Dear guRus I have xts data as: str(volsA) An ?xts? object on 2014-05-13/2015-04-07 containing: Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr [1:2] "vol1" "vol2" Indexed by objects of class: [Date] TZ: UTC xts Attributes: List of 1 $ na.action:Class 'omit' atomic [1:20] 1 2 3 4 5 6 7 8 9 10 ... .. ..- attr(*, "index")= num [1:20] 1.4e+09 1.4e+09 1.4e+09 1.4e+09 1.4e+09 ...>I am trying t0 plot them in a single frame but the scaling does not happen properly. plot(vols,plot.type="s",format="auto") lines(vols[,2],col="red") The lower graph in red gets displayed as a truncated graph and does not fully exhibit the relationship. Can someone kindly help in scaling/display please? Thanks Raghu
Joshua Ulrich
2015-Apr-07 16:47 UTC
[R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot
On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman Ramachandran <optionsraghu at gmail.com> wrote:> Dear guRus > > I have xts data as: > str(volsA) > An ?xts? object on 2014-05-13/2015-04-07 containing: > Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... > - attr(*, "dimnames")=List of 2 > ..$ : NULL > ..$ : chr [1:2] "vol1" "vol2" > Indexed by objects of class: [Date] TZ: UTC > xts Attributes: > List of 1 > $ na.action:Class 'omit' atomic [1:20] 1 2 3 4 5 6 7 8 9 10 ... > .. ..- attr(*, "index")= num [1:20] 1.4e+09 1.4e+09 1.4e+09 1.4e+09 > 1.4e+09 ... >> > I am trying t0 plot them in a single frame but the scaling does not > happen properly. > > plot(vols,plot.type="s",format="auto") > lines(vols[,2],col="red") > > The lower graph in red gets displayed as a truncated graph and does > not fully exhibit the relationship. Can someone kindly help in > scaling/display please? >What's the output of sessionInfo() from your R session?> Thanks > Raghu > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com
Raghuraman Ramachandran
2015-Apr-07 17:10 UTC
[R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot
Thanks Josh. I am not sure if I can attach a Jpeg. Please find attached. On Tue, Apr 7, 2015 at 5:47 PM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:> On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman Ramachandran > <optionsraghu at gmail.com> wrote: >> Dear guRus >> >> I have xts data as: >> str(volsA) >> An ?xts? object on 2014-05-13/2015-04-07 containing: >> Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... >> - attr(*, "dimnames")=List of 2 >> ..$ : NULL >> ..$ : chr [1:2] "vol1" "vol2" >> Indexed by objects of class: [Date] TZ: UTC >> xts Attributes: >> List of 1 >> $ na.action:Class 'omit' atomic [1:20] 1 2 3 4 5 6 7 8 9 10 ... >> .. ..- attr(*, "index")= num [1:20] 1.4e+09 1.4e+09 1.4e+09 1.4e+09 >> 1.4e+09 ... >>> >> I am trying t0 plot them in a single frame but the scaling does not >> happen properly. >> >> plot(vols,plot.type="s",format="auto") >> lines(vols[,2],col="red") >> >> The lower graph in red gets displayed as a truncated graph and does >> not fully exhibit the relationship. Can someone kindly help in >> scaling/display please? >> > What's the output of sessionInfo() from your R session? > >> Thanks >> Raghu >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > > > -- > Joshua Ulrich | about.me/joshuaulrich > FOSS Trading | www.fosstrading.com
William Dunlap
2015-Apr-07 17:29 UTC
[R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot
> plot(vols,plot.type="s",format="auto") > lines(vols[,2],col="red")Did you get any warning messages when you did that? I get > library(xts) > z <- xts(cbind(One=sin(1:20), Two=cos(1:20)+1.5), order.by =as.Date("2015-04-06")+(0:19)) > plot(z) Warning message: In plot.xts(z) : only the univariate series will be plotted and the y limits on the plot are at about c(-1,1). Thus the added points in z[,2] will not all be within the limits. You need to supply ylim=range(z) in the plot call if you want the limits to include the range of the second column of z. > plot(z[,1], ylim=range(z)) > lines(z[,2], col="red") Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Apr 7, 2015 at 9:47 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:> On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman Ramachandran > <optionsraghu at gmail.com> wrote: > > Dear guRus > > > > I have xts data as: > > str(volsA) > > An ?xts? object on 2014-05-13/2015-04-07 containing: > > Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... > > - attr(*, "dimnames")=List of 2 > > ..$ : NULL > > ..$ : chr [1:2] "vol1" "vol2" > > Indexed by objects of class: [Date] TZ: UTC > > xts Attributes: > > List of 1 > > $ na.action:Class 'omit' atomic [1:20] 1 2 3 4 5 6 7 8 9 10 ... > > .. ..- attr(*, "index")= num [1:20] 1.4e+09 1.4e+09 1.4e+09 1.4e+09 > > 1.4e+09 ... > >> > > I am trying t0 plot them in a single frame but the scaling does not > > happen properly. > > > > plot(vols,plot.type="s",format="auto") > > lines(vols[,2],col="red") > > > > The lower graph in red gets displayed as a truncated graph and does > > not fully exhibit the relationship. Can someone kindly help in > > scaling/display please? > > > What's the output of sessionInfo() from your R session? > > > Thanks > > Raghu > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > -- > Joshua Ulrich | about.me/joshuaulrich > FOSS Trading | www.fosstrading.com > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
Raghuraman Ramachandran
2015-Apr-07 21:52 UTC
[R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot
sessionInfo() R version 3.0.2 (2013-09-25) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RCurl_1.95-4.5 bitops_1.0-6 XML_3.98-1.1 xts_0.9-7 zoo_1.7-11 loaded via a namespace (and not attached): [1] grid_3.0.2 lattice_0.20-29 tools_3.0.2 TTR_0.22-0 Thanks Raghu On Tue, Apr 7, 2015 at 5:47 PM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:> On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman Ramachandran > <optionsraghu at gmail.com> wrote: >> Dear guRus >> >> I have xts data as: >> str(volsA) >> An ?xts? object on 2014-05-13/2015-04-07 containing: >> Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... >> - attr(*, "dimnames")=List of 2 >> ..$ : NULL >> ..$ : chr [1:2] "vol1" "vol2" >> Indexed by objects of class: [Date] TZ: UTC >> xts Attributes: >> List of 1 >> $ na.action:Class 'omit' atomic [1:20] 1 2 3 4 5 6 7 8 9 10 ... >> .. ..- attr(*, "index")= num [1:20] 1.4e+09 1.4e+09 1.4e+09 1.4e+09 >> 1.4e+09 ... >>> >> I am trying t0 plot them in a single frame but the scaling does not >> happen properly. >> >> plot(vols,plot.type="s",format="auto") >> lines(vols[,2],col="red") >> >> The lower graph in red gets displayed as a truncated graph and does >> not fully exhibit the relationship. Can someone kindly help in >> scaling/display please? >> > What's the output of sessionInfo() from your R session? > >> Thanks >> Raghu >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > > > -- > Joshua Ulrich | about.me/joshuaulrich > FOSS Trading | www.fosstrading.com