cdcaveman
cdcaveman

Reputation: 175

changing the side of bottom facet of graph in chart_Series quantmod

I would like to know if i can increase the size of the bottom pane of the graph on the plot function chart_Series()

chart_Series(x$A, TA="add_TA(x$B)")

you don't need data to know what this will look like...this shows the output of the chart_Series function with TA

Upvotes: 1

Views: 127

Answers (1)

FXQuantTrader
FXQuantTrader

Reputation: 6891

It is possible to modify some aspects of chart_Series using the pars and theme objects you can optionally pass to chart_Series. But I don't know if there is a way to feed in modifying the size of the y axis in add_TA etc without directly modifying the source code for add_TA. This is what I've done before, which is a bit messy, but works ... modify the source code.

The line in add_TA you want to modify is this, which is hard coded as (approximatly line 61 of add_TA):

plot_object$add_frame(ylim = range(na.omit(xdata)), 
            asp = 1)

Changing that line to this (the value of asp (aspect?) is changed), will give you something like what you want:

plot_object$add_frame(ylim = range(na.omit(xdata)), 
                      asp = 3)

This change gives:

getSymbols("AAPL")
chart_Series(AAPL["2016"])
my_add_TA(SMA(AAPL["2016", 4]))  #my_add_TA is add_TA with asp line changed

enter image description here If you're unsure about how to modify the source code of a package, you could follow my answer to a related question here modify chart_Series source on modifying chart_Series as one approach. Another approach is just to recompile the source code for the package with your modifications.

Upvotes: 1

Related Questions