In R, how do I make a (bar)plot's y axis labels parallel to the X axis instead of parallel to the Y axis?
5 Answers
186
votes
Not sure if this is what you mean, but try setting las=1
. Here's an example:
require(grDevices)
tN <- table(Ni <- stats::rpois(100, lambda=5))
r <- barplot(tN, col=rainbow(20), las=1)
That represents the style of axis labels. (0=parallel, 1=all horizontal, 2=all perpendicular to axis, 3=all vertical)
89
votes
19
votes
13
votes
1
votes
First, create the data for the chart
H <- c(1.964138757, 1.729143013, 1.713273714, 1.706771799, 1.67977205)
M <- c("SP105", "SP30", "SP244", "SP31", "SP147")
Second, give the name for a chart file
png(file = "Bargraph.jpeg", width = 500, height = 300)
Third, Plot the bar chart
barplot(H,names.arg=M,ylab="Degree ", col= rainbow(5), las=2, border = 0, cex.lab=1, cex.axis=1, font=1,col.axis="black")
title(xlab="Service Providers", line=4, cex.lab=1)
Finally, save the file
dev.off()
Output: