Skip to content

Commit

Permalink
Refactor add_TA to use y_grid_lines instead of custom function
Browse files Browse the repository at this point in the history
The original custom grid_lines function is very similar to y_grid_lines
in replot_xts object but the latter restricts the output values to
the upper limit and lower limit. About two intervals will be
dropped so the labels of prior chart will not be blocked.
  • Loading branch information
erichung0404 committed Aug 10, 2016
1 parent 4c1a341 commit 90a419c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions R/chart_Series.R
Original file line number Diff line number Diff line change
@@ -522,10 +522,8 @@ add_TA <- function(x, order=NULL, on=NA, legend="auto",

plot_object$add_frame(ylim=range(na.omit(xdata)),asp=1) # need to have a value set for ylim
plot_object$next_frame()
# add grid lines, using custom function for MACD gridlines
lenv$grid_lines <- function(xdata,xsubset) {
pretty(xdata[xsubset])
}
# add grid lines, using y_grid_lines function from replot_xts object
lenv$grid_lines <- plot_object$Env$y_grid_lines
exp <- c(expression(segments(1,grid_lines(xdata,xsubset),NROW(xdata[xsubset]),grid_lines(xdata,xsubset),
col=theme$grid)), exp, # NOTE 'exp' was defined earlier to be plot_macd
# add axis labels/boxes

0 comments on commit 90a419c

Please sign in to comment.