Does chart_Series() work with logarithmic axis?

2019-07-03 10:54发布

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.

标签: r quantmod
2条回答
祖国的老花朵
2楼-- · 2019-07-03 11:26

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))

查看更多
地球回转人心会变
3楼-- · 2019-07-03 11:29

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)
查看更多
登录 后发表回答