0
爲了使我的圖形呈現出來,我試圖在x軸上移動刻度標籤。我想移動標籤,所以不會碰到圖表和數據。我目前的圖形代碼如下:如何更改R中的x刻度標籤(移動標籤和更改角度)
ggplot(Duffel_plotdat, aes(Afkorting, est)) + geom_point() + geom_errorbar(aes(ymin=est-se, ymax=est+se)) + labs(title="Variance loggers for each AHS") + xlab("Artificial hibernation structures") + ylab("Variance") +
scale_x_discrete(breaks=c("BL","BW","H","K","MB","MCD","WK"),
labels=c("Loose in brick", "In brick closed\nwith cotton wool", "Square\nceiling box", "Wall logger\ndirectly on wall", "Wall logger\non wooden cube", "Middle of\nCD-rack", "Wall plate box")) +
theme(axis.text.x = element_text(angle=45))
給予該圖:
我發現關於這個主題(change the position (move) of tick labels when plotting with matplotlib)另一個問題,但由於數字不再可用,我不能真的確定這是否對我有幫助。
最後我想遷移角度,以便標籤名稱以另一種方式傾斜(從左上角到右下角)。我試圖這樣做使用
angle=135
使角度rigth,但將文本倒過來。
你會想用'element_text'的'hjust'和/或'vjust'鼓搗。老實說,我永遠不會記得正確的組合,讓標籤在正確的位置,我總是不得不嘗試2-3次,才能得到正確的組合。 – joran
您可以嘗試通過調整偏移:http://stackoverflow.com/questions/14487188/increase-distance-between-text-and-title-on-the-y-axis –
對於角度,嘗試-45(或315 )。對於hjust和vjust,正確的值將介於0和1之間,但像@joran一樣,我永遠不會記得正確的組合。 – eipi10