无法在R中的绘图上旋转标签

时间:2016-01-06 19:02:18

标签: r plot labels

不知何故,我似乎无法在下面的代码中显示我的情节上的标签。否则图形看起来很好,如果我不使用文本选项,轴显示正常,但我试图将x轴旋转45度以使其更具可读性。

  png( file=fn,units='in', width=7,height=7,pointsize=10, res=350,type='cairo')
  pts = c(19, 22, 24)
  lns = c(1, 3, 1)
  cols = c("grey10", "grey10",  "grey20")
  yrange = c(0, 12760)
  xrange = c(1978, 2015)
  xrange[1] = xrange[1]
  xrange[2] = xrange[2]
  xlabels = seq(xrange[1]+1, xrange[2], 2)

  m=1; plot( uyrs, l[,m],  type="b", ylab="Landings (t)", xlab="Year", col=cols[m], lwd=4, lty=lns[m], pch=pts[m], xaxt="n", xlim=xrange, ylim=yrange)
  m=2; points(uyrs, l[,m], type="b", col=cols[m], lwd=3, lty=lns[m], pch=pts[m])
  m=3; points(uyrs, l[,m], type="b", col=cols[m], lwd=3, lty=lns[m], pch=pts[m])
  axis(1, at=xlabels, labels=FALSE)
  text(x=xlabels, labels=xlabels, srt=45, adj=1, xpd=TRUE)
  legend(x=1980, y=8500, c("N-ENS", "S-ENS", "4X"), bty="n", lty=lns, lwd=3, pch=pts, col=cols, cex=1.4 )

  dev.off()

Here is the plot I am trying to add labels to. The tic marks show up at the proper locations

0 个答案:

没有答案