[R-SIG-Finance] plot.xts/chart_Series, multi.panel and candlesticks

Joshua Ulrich jo@h@m@u|r|ch @end|ng |rom gm@||@com
Sun Sep 5 16:16:28 CEST 2021


Hi Mike,


On Sun, Sep 5, 2021 at 8:36 AM Mike <mike9 using posteo.nl> wrote:
>
> I like to plot two candlesticks charts (e.g. two stocks) stacked in
> the same plot.
>
> With plot.xts I found some examples
> http://joshuaulrich.github.io/xts/plotting_panels.html
> https://github.com/joshuaulrich/xts/issues/140
> for using the multi.panel option but only for one-column-data. Since
> candlesticks need four columns of data I wonder how to tell plot.xts
> which columns to use for panel 1 and which for panel 2.
>
> Given two stocks
> getSymbols('AAPL')
> getSymbols('MSFT')
>
> Would I have to merge them into a new xts or pass them to plot.xts
> separately?
>
You can use the layout() function to split the plot into multiple
sections. There are more examples on the plotting_panels page you
referenced.

layout(matrix(1:2))
chart_Series(AAPL)
chart_Series(MSFT)

> Mike
>
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com



More information about the R-SIG-Finance mailing list