所以設置是這樣的:添加網格單元對象
dat <- data.frame(a = c("longnameonthelefthandside"), b = c(sample(10)))
p <- ggplot(dat, aes(b,a)) + geom_point() + xlab("label")
我可以通過調整x軸標籤一個unit
對象hjust
:
p + opts(axis.title.x=theme_text(size=12,hjust=unit(0.3,"npc")))
但還有一些關於添加單元對象(可能,根據?單位)我沒有把握:
u1 <- unit(0.5,"npc")
u2 <- unit(0.25,"npc")
p + opts(axis.title.x=theme_text(size=12,hjust=u1+u2))
產生foll由於錯誤:
Error in grid.Call("L_textBounds", as.graphicsAnnot(x$label), x$x, x$y, :
Polygon edge not found
In addition: Warning message:
In validDetails.text(x) : NAs introduced by coercion
至於進一步情況下,我試圖通過巴蒂斯特here
+1不錯的問題。我不知道你可以對ggplot中對象的位置進行這種控制。 – Andrie