Reputation: 43
To make my graph presentable I'm trying to move the tick labels on the x-axis. I'd like to move the labels, so the don't run into the graph and over the data. My current code for the graph is as follows:
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))
Giving this graph:
I found another question on this topic (change the position (move) of tick labels when plotting with matplotlib) but since the figures are no longer available, I can't really determine if this helps me.
Finally I'd migth want to change the angle, so that the label names incline in the other way (diagonal from top left, to bottom right). I tried to do so using
angle=135
making the angle rigth, but putting the text upside down.
Upvotes: 1
Views: 8125
Reputation: 43
Using the following code:
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(vjust=0.6, angle=-45))
Gives the following figure:
Upvotes: 3