3
votes

Is there a way to produce logarithmic y-axis with chart_Series()? I am using the experimental chart_Series() rather than the chartSeries() method in quantmod, because it is more convenient when adding additional lines to the plot.

library(quantmod)
POWR <- getSymbols("POWR", auto.assign=FALSE)

# the following attempts did not produce logarithmic axis for y
chart_Series(POWR, log.scale=TRUE)  # like in chartSeries()
chart_Series(POWR, log="y")         # like in plot.default()

From a quick look into the code, it does not seem to be possible using existing chart_pars() or chart_theme() methods for customization, too.

Thank you very much for any help.

2
I'm trying to port some existing chartSeries code and am stuck on this functionality. has anyone found a way to log scale the axes? plotting the log of the underlying values is not a viable solutionEthan

2 Answers

1
votes

If you don't need an OHLC chart and the Close is all you need you can use the chart.TimeSeriesfunction from the 'PerformanceAnalytics' - package, where you have lots of options to customize the chart.

chart.TimeSeries(cumprod(1+ ROC(POWR, type = "discrete")[-1,6]),ylog = TRUE,minor.ticks =FALSE)
0
votes

Your extra arguments don't work because they aren't expected as passthrough parameters (via ...) to any function inside chart_Series. If you simply want log candles, try chart_Series(log(POWR))