首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打印时忽略cex.main [xts]

打印时忽略cex.main [xts]
EN

Stack Overflow用户
提问于 2019-01-14 07:15:44
回答 1查看 498关注 0票数 2

我有一些xts数据,我想减小"main“文本的大小,但使文本的其余部分保持原始大小。因此,我尝试使用cex.main,但这不起作用。唯一有效的函数是cex,但这会改变我所有文本的大小,而不仅仅是正文。

这是我当前的代码和数据:

代码语言:javascript
复制
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

任何帮助都会很感谢,谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-01-14 18:12:21

我总是恢复使用base R绘图选项。给了我我想要的。在这种情况下,您可以执行的操作如下所示。在创建绘图时,我强制主标题为空,然后使用title设置所有正确的选项。plot.xts使用自己的打印设备,而不是使用base R打印选项。我倾向于否决这些,以给我更多的控制权。

代码语言:javascript
复制
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功能,但是它在绘制您想要的数据方面有一个很小的学习曲线,就像您所拥有的那样。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54174098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档