[R-SIG-Finance] layout options of barChart in quantmod
Jeff Ryan
jeff.a.ryan at gmail.com
Thu Nov 13 16:24:23 CET 2008
This should clarify (from a previous off-list exchange):
Before calling any chartSeries function (including barChart), use the
R 'layout' function. see ?layout
Each window is technically a plot region, so count the TA _windows_ when
you do this.
getSymbols("SPY;DIA;QQQQ;IWM")
layout(matrix(1:8, nrow=4), height=c(4,2.5,4,2.5))
Then set layout=NULL in each call.
chartSeries(IWM, layout=NULL)
chartSeries(SPY, layout=NULL)
chartSeries(DIA, layout=NULL)
chartSeries(QQQQ, layout=NULL)
You need to have a constant 'theme', or funny things will happen.
Other arrangements are possible, though require you to really get your
head around 'layout'. I will one day be adding in a chartLayout tool
that will make this easier, but for now it is at least doable.
layout(matrix(c(1,1,1,2,3:6), nrow=4), height=c(4,2.5,4,2.5))
chartSeries(QQQQ, layout=NULL)
chartSeries(QQQQ, layout=NULL)
chartSeries(QQQQ, layout=NULL)
You won't be able to use this interactively once the chart is drawn
--- i.e. calling addTA to dynamically add TA additions. The layout
needs to be calculated before any of the drawing takes place. This is
what happens internally when you call addTA/chartSeries,, which is why
setting layout=NULL places the burden on you the user.
HTH,
Jeff
On Thu, Nov 13, 2008 at 8:11 AM, 风 <windspeedo at qq.com> wrote:
> quantmod is a fantastic tool for R. The only problem I could not overcome is about the layout option in barChart.
> The help document only said that "layout: if NULL bypass internal layout ".
> But how could I produce the chart as shown in http://www.quantmod.com/gallery/ ?
> What value should I set the layout to obey the previous layout settings in R?
> Thanks.
>
> Wind
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
--
Jeffrey Ryan
jeffrey.ryan at insightalgo.com
ia: insight algorithmics
www.insightalgo.com
More information about the R-SIG-Finance
mailing list