1
votes

I have a bar plot in R plotting probability distributions on the following data

example data:

 mc2
[1] 0.03846154 0.09615385 0.19230769 0.18269231 0.28846154 0.20192308 
> mc2dl
[1] 143 144 145 146 147 148 ### used as x axis labels

when I try to plot this the x axis appears vertically

barplot.default(mc2, xlab = mc2dl)

Example plot

And when plotting my own axis its length does not = the size of the graph

axis(1, 1:6, labels=mc2dl)

example plot 2

p.s I have tried ggplot but it brings its own problems, regarding multiple plots side by side and is in a different format than the rest of my paper.

Thanks in advance

1

1 Answers

1
votes

The barplot object itself contains information about the position of its own bars, so you can do:

my_barplot <- barplot(mc2)
axis(1, at = my_barplot, labels = 143:148)

enter image description here