簡體   English   中英

在R中使用Matplot更改軸標簽

[英]Change axis labels with matplot in R

我正在嘗試在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)

plot我用這個沒有問題。 我該如何解決? 在這里可以找到對象: https : //dl.dropboxusercontent.com/u/47720440/SOF.RData

我通常這樣做如下:

  1. 完全省略軸。
  2. 逐一添加具有所需選項的軸。

在R中:

# Add argument axes=F to omit the axes
matplot(t(DataMatrix),type='l',col="black",lwd=1,xlab="Anni",ylab="Rifiuti",main="Produzione rifiuti",axes=F)

# Add Y-axis as is
axis(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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM