问题
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)
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.
Any help is appreciated!
回答1:
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()
来源:https://stackoverflow.com/questions/20355679/using-r-to-make-a-barplot-with-a-specific-width