我有一些xts数据,我想减小"main“文本的大小,但使文本的其余部分保持原始大小。因此,我尝试使用cex.main,但这不起作用。唯一有效的函数是cex,但这会改变我所有文本的大小,而不仅仅是正文。
这是我当前的代码和数据:
pdf("52_week_ratio_of_technology_to_dispatch_weighted_moving_average_SA.pdf",onefile=TRUE)
plot(ratio_data_dated[, grep("Gas|Coal", names(ratio_data_dated))],
legend(grep("Gas|Coal", names(ratio_data_dated))),
cex=0.45,
col = c("red", "blue"),
main = "SA: 52 week moving average of ratio of technology to time weighted price",
legend.loc = "topleft")
dev.off()
> head(ratio_data_dated)
Battery Brown.Coal Gas Liquid.Fuel Rooftop.PV Solar Wind
2011-01-01 0 1.0301403 1.380166 9.023921 0 0 0.9038254
2011-01-08 0 0.9390685 1.214767 6.662844 0 0 0.7722963
2011-01-15 0 1.0262270 1.288217 6.116886 0 0 0.7821223
2011-01-22 0 1.0299489 1.292552 6.116968 0 0 0.7843045
2011-01-29 0 1.0752547 1.531712 7.580647 0 0 0.8201304
2011-02-05 0 0.8692285 1.286059 6.160726 0 0 0.6858254
> str(ratio_data_dated)
An ‘xts’ object on 2011-01-01/2018-12-29 containing:
Data: num [1:418, 1:7] 0 0 0 0 0 0 0 0 0 0 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:7] "Battery" "Brown.Coal" "Gas" "Liquid.Fuel" ...
Indexed by objects of class: [POSIXct,POSIXt] TZ:
xts Attributes:
NULL任何帮助都会很感谢,谢谢。
发布于 2019-01-14 18:12:21
我总是恢复使用base R绘图选项。给了我我想要的。在这种情况下,您可以执行的操作如下所示。在创建绘图时,我强制主标题为空,然后使用title设置所有正确的选项。plot.xts使用自己的打印设备,而不是使用base R打印选项。我倾向于否决这些,以给我更多的控制权。
plot(ratio_data_dated[, grep("Gas|Coal", names(ratio_data_dated))],
main = NULL)
addLegend("topleft",
on = 1,
lty = 1
)
title(main = "SA: 52 week moving average of ratio of technology to time weighted price", cex.main = 0.45)您可能需要查看一个名为rtsplot的小程序包。这些都是xts对象的基本R功能,但是它在绘制您想要的数据方面有一个很小的学习曲线,就像您所拥有的那样。
https://stackoverflow.com/questions/54174098
复制相似问题