Set Aspect Ratio of Scatter Plot and Bar Plot in R Programming – Using asp in plot() Function
asp
is a parameter of the plot()
function in R Language is used to set aspect ratio of plots (Scatterplot and Barplot). Aspect ratio is defined as proportional relationship between width and height of the plot axes.
Syntax: plot(x, y, asp )
Parameters:
x, y: Coordinates of x and y axis
asp: Aspect ratio
Example 1:
set.seed (86000)
x <- runif (120)
y <- x + runif (120)
plot (x, y)
plot (x, y, asp = 5)
|
Output:
- Plot Without Aspect Ratio:
- Plot with Aspect Ratio:
Example 2:
set.seed (86000)
x <- runif (120)
y <- x + runif (120)
barplot (x)
barplot (x, asp = 5)
|
Output:
- Bar Plot Without Aspect Ratio:
- Bar Plot with Aspect Ratio:
Here, the asp option increases the width of the y-axis.
Last Updated :
30 Jun, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...