-
I have the following piece of code for a graph:
barplot(as.vector(t(mat1[1,3:ncol(mat1)])),las=2)
that I would like to alter so that the x-axis is replaced by the line y = 2; effectively moving the x-axis up 2 units as in the image below.

I need the bars to begin at 2 so that:
- a bar with a value of 3 begins from the y=2 line and ascends to end at y=3.
- a bar with a value of 0 begins from the y=2 line and descends to end at y=0
-
How can I make the column names of
mat1my x-axis categories?
I have the following piece of code for a graph: barplot(as.vector(t(mat1[1,3:ncol(mat1)])),las=2) that I would
Share
Barplot always starts its bars at 0. Subtract 2 (or 5 as I did) from every y-value. Set ylim to range(y-values – 5). You will need to suppress plotting the y axis with yaxt=”n”. The xpd parameter to axis allows the range of labels to extend below the range of actual values.