【发布时间】:2019-04-26 22:57:45
【问题描述】:
我有一个名为 adjPrices.xts 的 xts 对象,其中包含 OHLC 股票价格历史记录。函数 quantmod::chartSeries 调用如下时,会将这些数据绘制在黑色背景的图表中:
chartSeries(adjPrices.xts,
subset = '2014-07-01::2015-07-01',
type = 'bars',
name = paste(symbol, 'Adjusted Prices'),
TA = NULL)
但是,具有相同选项的 quantmod::chart_Series 会创建一个白色背景的图表:
chart_Series(adjPrices.xts,
subset = '2014-07-01::2015-07-01',
type = 'bars',
name = paste(symbol, 'Adjusted Prices'),
TA = NULL)
我想将第二个绘图的背景颜色更改为黑色,并且我正在遵循this answer 中建议的方法。 chart_theme() 的颜色属性为
> chart_theme()$col
$`bg`
[1] "#FFFFFF"
$label.bg
[1] "#F0F0F0"
$grid
[1] "#F0F0F0"
$grid2
[1] "#F5F5F5"
$ticks
[1] "#999999"
$labels
[1] "#333333"
$line.col
[1] "darkorange"
$dn.col
[1] "red"
$up.col
[1] NA
$dn.border
[1] "#333333"
$up.border
[1] "#333333"
这表明我可以将背景颜色设置为黑色,如下所示:
myTheme <- chart_theme()
myTheme$col$`bg` <- "black"
chart_Series(adjPrices.xts,
subset = '2014-07-01::2015-07-01',
theme = myTheme,
type = 'bars',
name = paste(symbol, 'Adjusted Prices'),
TA = NULL)
但生成的图表仍然有白色背景:
我还尝试如下定义myTheme:
myTheme <- chart_theme()
myTheme$col$`bg` <- "#000000"
但生成的图表仍然有白色背景。
使用chart_Series()时如何设置黑色背景?
【问题讨论】: