Krysta
Krysta

Reputation: 220

Change orientation of barplot() in R

I am working on making two back-to-back barplots with the traditional graphics package in R; I have found the horiz argument to the barplot() function, but can't figure out how to flip the horizontally-oriented graph horizontally.

As an example,

barplot(mtcars$cyl, horiz = T)

gives

enter image description here

but what I want to make is this (with the x-axis correct, of course).

enter image description here

Is there a way to do this with the traditional graphics package?

Upvotes: 2

Views: 6539

Answers (1)

Jilber Urbina
Jilber Urbina

Reputation: 61214

Something like this...?

barplot(-mtcars$cyl, horiz = TRUE, axes=FALSE)
axis(1, at=-0:-8, labels=0:8)

enter image description here

Upvotes: 1

Related Questions