[R-SIG-Finance] quantmod custom layouts

Jeff Ryan jeff.a.ryan at gmail.com
Thu Mar 12 21:18:46 CET 2009

Hi Brian,

I need to make this easier, and document it better, but this will get
you started. There are slides from my presentations at Rmetrics 2008
and Columbia on the quantmod website.

(From a previous post on the same topic)

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.

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.


R/Finance 2009: Applied Finance with R
April 24, 25 Chicago, IL USA

[original here:]

On Thu, Mar 12, 2009 at 3:06 PM, B Kim <briankim19 at yahoo.com> wrote:
> Hi,
> I just started using quantmod and R.  Can someone tell me how to use the custom layouts?  For example, I just want to have 2 stock charts with indicators on the same page.
> thanks,
> Brian
>        [[alternative HTML version deleted]]
> _______________________________________________
> 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

More information about the R-SIG-Finance mailing list