从 xts 对象的图中删除 y 轴标签 [英] Remove y-axis label from plot of an xts object
本文介绍了从 xts 对象的图中删除 y 轴标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是生成 xts 对象图的代码:
Here is the code generating a plot of an xts object:
require("quantmod")
getSymbols("SPY")
plot(Cl(SPY))
产生以下图:
您能否从 xts 对象的图中删除 y 轴值(价格)?
Can you remove the y-axis values (the prices) from a plot of an xts object?
提示:通过 yaxt='n'
不起作用.
推荐答案
移除 y 轴很容易,但也会移除 x 轴.几个选项:
Removing the y-axis is easy, but it also removes the x-axis. A couple options:
1) 简单 -- 使用 plot.zoo
:
1) Easy -- use plot.zoo
:
plot.zoo(Cl(SPY), yaxt="n", ylab="")
2) Harder-ish -- 从 plot.xts
中取出片段:
2) Harder-ish -- take pieces from plot.xts
:
plot(Cl(SPY), axes=FALSE)
axis(1, at=xy.coords(.index(SPY), SPY[, 1])$x[axTicksByTime(SPY)],
label=names(axTicksByTime(SPY)), mgp = c(3, 2, 0))
3) Customize-ish -- 修改 plot.xts
以便 axes=
接受要绘制的轴向量和/或 TRUE
/假
.
3) Customize-ish -- modify plot.xts
so axes=
accepts a vector of axes to plot and/or TRUE
/FALSE
.
这篇关于从 xts 对象的图中删除 y 轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文