user1398057
user1398057

Reputation: 1159

In R plots, how can we make the length of an x-axis several times longer than the y-axis?

Currently, I am trying to stretch out the x-axis of a plot to search for things like seasonality, etc. Meaning, I would possibly like my x-axis to be 6 times or so longer than my y-axis, while keeping the ticks and data the same. An example:

x <- rnorm(20)^2 * 1000000
plot(x)

enter image description here

Is there a way to make the x-axis above much longer than the y-axis? Thanks!

Upvotes: 0

Views: 3138

Answers (1)

Ruthger Righart
Ruthger Righart

Reputation: 4921

The commands below are writing it to a .png file with different width. The files fig1.png and fig2.png are saved to your home directory.

png("fig1.png", width = 400, height = 300)
x <- rnorm(20)^2 * 1000000
plot(x)
dev.off()

png("fig2.png", width = 600, height = 300)
x <- rnorm(20)^2 * 1000000 #or leave this out if you want the same data x 
plot(x)
dev.off()

Upvotes: 1

Related Questions