如何在下面的网格图中正确旋转y轴的标签(使用grid.yaxis()
创建)?这个想法可以在Paul Murrell的书中找到,但由于某种原因,它失败了。一个有效的版本是使用grid.edit("yaxis1", edits=gEdit("labels", rot=90))
,如下所示,但标签不再正确地居中于刻度线......
require(grid)
X <- matrix(rexp(2000), ncol=2)
grid.newpage()
pushViewport(plotViewport(c(4,4,4,4)))
pushViewport(dataViewport(X[,1], X[,2]))
grid.points(X[,1], X[,2], pch=1)
grid.rect()
grid.xaxis()
grid.yaxis(name="yaxis1")
grid.edit("yaxis1", edits=gEdit("labels", rot=90))
#grid.edit("yaxis1::labels", rot=90) # => fails with "Error in editDLfromGPat(hgPath, specs, strict, grep, global, redraw) : 'gPath' (yaxis1::labels) not found"
upViewport()