I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below:
barplot(((data1[,1] - average)/average) * 100, srt = 45, adj = 1, xpd = TRUE, names.arg = data1[,2], col = c("#3CA0D0"), main = "Best Lift Time to Vertical Drop Ratios of North American Resorts", ylab = "Normalized Difference", yaxt = 'n', cex.names = 0.65, cex.lab = 0.65)
Method 1: Using barplot() To display all the labels, we need to rotate the axis, and we do it using the las parameter. To rotate the label perpendicular to the axis we set the value of las as 2, and for horizontal rotation, we set the value as 1. Secondly, to increase the font size of the labels we use cex.
Rotate X-Axis Tick Labels in Matplotlib There are two ways to go about it - change it on the Figure-level using plt. xticks() or change it on an Axes-level by using tick. set_rotation() individually, or even by using ax.
To set X, Y axes labels for Bar Plot drawn using barplot() function, pass the required label values for xlab parameter and ylab parameter in the function call respectively. xlab parameter is optional and can accept a value to set X-axis label for the bar plot.
use optional parameter las=2 .
barplot(mytable,main="Car makes",ylab="Freqency",xlab="make",las=2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With