使用 quantmod chartSeries 在 R 中绘制日内 OHLC 数据的问题 [英] Problems plotting intraday OHLC data in R with quantmod chartSeries

查看:63
本文介绍了使用 quantmod chartSeries 在 R 中绘制日内 OHLC 数据的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 xts/zoo 对象 ESZ1:

I have an xts/zoo object ESZ1:

> class(ESZ1) 
[1] "xts" "zoo"

> class(time(ESZ1))
[1] "POSIXt"  "POSIXct"

> colnames(ESZ1)
[1] "ESZ1.Open"    "ESZ1.High"    "ESZ1.Low"     "ESZ1.Close"   "ESZ1.Volume"  "ESZ1.WAP"     "ESZ1.hasGaps" "ESZ1.Count"  

我想使用 quantmod 包中的 chartSeries 函数绘制它.但是,我收到以下错误:

and I would like to plot it using the chartSeries function from the package quantmod. However, I get the following error:

> chartSeries(ESZ1)
Error in if (on == "years") { : missing value where TRUE/FALSE needed

任何有关问题可能是什么的想法将不胜感激.

Any ideas of what the problem could be would be greatly appreciated.

补充问题:是否有关于如何调整 chartSeries() 的轴/边距的文档?目前,我的 y 轴标签在图的右侧边缘被部分切断.我试过使用

Additional question: Is there any documentation for how to adjust the axes/margins for chartSeries()? Currently my y-axis labels are partially cut off on the right-hand margin of the plot. I've tried using

mar = ...

在chartSeries的参数列表中,但这并没有改变结果图.

in the argument list of chartSeries, but this did not change the resulting plot.

推荐答案

问题出在 chartSeries 中,特别是 axTicksByTime 调用.我会添加一个补丁来解决这个问题,但现在你可以这样做:

The issue is within chartSeries, specifically the axTicksByTime call. I'll add a patch to fix this, but for now you can do:

chartSeries(ESZ1, major.ticks="minutes")

默认情况下 major.ticks="auto" 并且它似乎在自动魔法过程中过早失败,无法得到正确答案.

By default major.ticks="auto" and it seems to fail too early in the automagical procedure to get to the right answer.

这篇关于使用 quantmod chartSeries 在 R 中绘制日内 OHLC 数据的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆