quantmod custom layouts
Hi Brian, There is a new function in quantmod to save the chart (though not in the CRAN version yet). It doesn't do much more than: dev.copy2pdf(file="AAPL.pdf") Which will do what you want. The interactive nature of the chartSeries logic makes using it on other devices not quite as smooth as one would like/expect. But it can be done. (see ?dev.copy) HTH, Jeff
On Thu, Mar 12, 2009 at 3:40 PM, B Kim <briankim19 at yahoo.com> wrote:
Fantastic, thats exactly what I was looking for! Also, how can I change the colors of the technical indicator lines?? I use the "white" theme to save on ink when printing, but the dashed line in the addSMI call is very hard to see. ??? chartSeries(AAPL, layout=NULL, up.col='white', dn.col = 'blue', theme="white", TA="addBBands();addSMI();") ??? addLines(h=-25, on = 2, col = "red") ??? addLines(h=25,? on = 2, col = "red") Last question, whats the best way to add overbought and oversold lines? When I use the above code and write to a pdf, I get pages in the pdf file. The first page contains the chart and indicators, the 2nd page contains the same but has a line added at -25, and the 3rd page contains lines at -25 and 25. thanks again, Brian
________________________________
From: Jeff Ryan <jeff.a.ryan at gmail.com>
To: B Kim <brian.a.kim at gmail.com>
Cc: r-sig-finance at stat.math.ethz.ch
Sent: Thursday, March 12, 2009 4:18:46 PM
Subject: Re: [R-SIG-Finance] quantmod custom layouts
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.
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
R/Finance 2009: Applied Finance with R
April 24, 25 Chicago, IL USA
http://www.RinFinance.com
[original here:]
http://www.nabble.com/layout--options-of--barChart-in-quantmod-tt20481570.html#a20481570
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
www.insightalgo.com
_______________________________________________
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