使用R制作具有特定宽度的条形图?

编程入门 行业动态 更新时间:2024-10-27 08:30:59
本文介绍了使用R制作具有特定宽度的条形图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用R绘制一个〜100,000个数字条目的小节图.情节将是密集的,这就是我想要的.到目前为止,我正在使用以下代码:

I would like to use R to make a barplot of ~100,000 numerical entries. The plot will be dense, which is what I want. So far I am using the following code:

sample_var <- c(2,5,3,2,3,2,6,10,20,...) #Filled with 100,000 entries barplot(sample_var)

生成的图正是我想要的,但是它是一个正方形,而我想要一个长矩形.有没有一种方法可以设置条形图的尺寸?我想将长x高指定为10:1的宽高比,或将1000px x 10px设置为特定的像素.我尝试在barplot函数语句中使用 xlim ,但收到无效的xlim"警告.

The resulting plot is just what I want, but it is a square, whereas I want a long rectangle. Is there a way to set the dimensions of the barplot? I would like to specific an aspect ratio of 10:1 for length x height, or a specific pixel setting of 1000px x 10px. I tried using xlim in the barplot function statement, but get an "invalid xlim" warning.

感谢您的帮助!

推荐答案

在输出到文件时设置 width 和 hight :

Set the width and hight when outputting to a file:

png(filename="figures.png", width=800, height=200, bg="white") sample_var <- c(2,5,3,2,3,2,6,10,20) barplot(sample_var) dev.off()

更多推荐

使用R制作具有特定宽度的条形图?

本文发布于:2023-07-18 04:30:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:宽度   条形图

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!