Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rotate labels in grid.xaxis

Tags:

r

r-grid

It doesn't seem to be possible to rotate the labels of an xaxis using grid.xaxis(at=, lab=) by e.g. 90 degrees using a gpar-option.

Anybody knows a workaround apart from creating separate viewports and using grid.text()?

like image 256
user1142774 Avatar asked Dec 22 '22 03:12

user1142774


2 Answers

Try this,

grid.xaxis(seq(0,1,by=0.1), vp=viewport(y=1), 
           edits = gEdit(gPath="labels", rot=90))
like image 150
baptiste Avatar answered Dec 24 '22 01:12

baptiste


Check this document: An Example of Interactive Graphics Editing in Grid

library("grid")
gxa <- xaxisGrob(at = 1:4/5, vp = viewport(w = 0.5, h = 0.01))
gxa <- editGrob(gxa, gPath = "labels", gp = gpar(col = "black"), rot=90)
grid.draw(gxa)
like image 25
rcs Avatar answered Dec 24 '22 02:12

rcs