简体   繁体   English

在R中更改barplot()的方向

[英]Change orientation of barplot() in R

I am working on making two back-to-back barplots with the traditional graphics package in R; 我正在使用R中的传统图形包制作两个背对背的条形图。 I have found the horiz argument to the barplot() function, but can't figure out how to flip the horizontally-oriented graph horizontally. 我已经找到了barplot()函数的horiz参数,但无法弄清楚如何水平翻转水平方向的图。

As an example, 举个例子,

barplot(mtcars$cyl, horiz = T)

gives

在此处输入图片说明

but what I want to make is this (with the x-axis correct, of course). 但是我想做的就是这个(当然,x轴正确)。

在此处输入图片说明

Is there a way to do this with the traditional graphics package? 使用传统的图形包有办法做到这一点吗?

Something like this...? 这样的东西...?

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

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM