It is easy to make a barplot in R (using the barplot() function). The default is to have vertical bars that start at the bottom and go up (i.e., the base is at side=1). Furthermore, you can make a barplot with the base on the left (side=1) by using the horiz=T argument. I would like to make a barplot with the base of the bars on the right (side=4).
- How do you do this?
- How can you make the base at the top (side=3)?
I would prefer to be able to do this with the base graphics, if possible.
One quick option (probably a bit of a kludge) is to just multiply all of your data by -1, then the bars will go down or left from the axis instead of up or right. You might want to supress the x axis and manually put in the values without the negative sign.
Other options are to write your own function that draws the boxes from the axis you choose using the
rector other command.Or use grid graphics and use a rotated viewport (this would require abandoning the base raphics however).
Edit
Actually there turns out to be a less kludgy way to use the base
barplotfunction, see this example (and modify for your situation).You will need to replace the 5 in the
xlimargument with something based on your data, either the maximum value, the maximum of the sums, the previous times 1.04, etc.This will still label the bars on the left (if you give it labels), but you can supress that axis and manually put the axis on the right if that is what you prefer.