带一个条的R条形图-如何正确绘制 [英] R Barplot with one bar - how to plot correctly

查看:102
本文介绍了带一个条的R条形图-如何正确绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在R中绘制常规条形图,但只有一个条形图.我不喜欢这样的事实,即条形宽度变为整个图的宽度.我希望酒吧变得更稀薄",但我不知道该怎么做.

I want to plot a regular bar plot in R, but with just one bar. What I don't like is the fact that the bar width gets to be the width of the whole plot. I want the bar to be "thinner", but I don't know how to do it.

默认命令是:

barplot(percentage, col=c("brown4")) 

其中百分比是分数.我尝试使用xlim参数,但它变得非常混乱(条形图完全移至右侧或左侧).例如,我尝试过:

where percentage is a fraction. I tried using xlim parameter, but it gets very messy (bar goes completely to the right or left). For example, I tried:

barplot(percentage, col=c("brown4"), xlim=c(0.5,1))

但是,这会进一步扩大标准.我是R菜鸟.

but this stretches the bar even more. I am an R noob.

推荐答案

您可以尝试使用要绘制的设备的宽度.例如:

You may try to play around with the width of the device you plotting to. E.g.:

# plot to a Windows graphic device
windows(height = 10, width = 4)
barplot(0.5)

# plot to PDF
pdf(height = 10, width = 2)
barplot(0.5)
dev.off()

您也可以将widthxlim

barplot(0.5, width = 0.1, xlim = c(0, 1))

这篇关于带一个条的R条形图-如何正确绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆