gpt4 book ai didi

r - 在 R 中使用 matplot 更改轴标签

转载 作者:行者123 更新时间:2023-12-05 08:23:53 25 4
gpt4 key购买 nike

我正在尝试更改 matplot 中的 x 轴,但此命令不起作用:

TimePoints=1997:2011
matplot(t(DataMatrix),type='l',col="black",lwd=1,xlab="Anni",ylab="Rifiuti",main="Produzione rifiuti")
axis(side=1,at=TimePoints,labels=TimePoints)

with plot 我用这个没有问题。我该如何解决?您可以在这里找到对象:https://dl.dropboxusercontent.com/u/47720440/SOF.RData

最佳答案

我通常这样做:

  1. 完全省略轴。
  2. 将具有所需选项的坐标轴一一添加。

在 R 中:

# Add argument axes=F to omit the axesmatplot(t(DataMatrix),type='l',col="black",lwd=1,xlab="Anni",ylab="Rifiuti",main="Produzione rifiuti",axes=F)# Add Y-axis as isaxis(2)# Add X-axis# Note that your X-axis range is not in years but in the "column numbers",# i.e. the X-axis range runs from 1 to 15 (the number of columns in your matrix)# Possibly that's why your original code example did not work as expected?axis(side=1,at=1:ncol(DataMatrix),labels=TimePoints)

关于r - 在 R 中使用 matplot 更改轴标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29253659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com