Data visualization in R: Change the aspect ratio for a plot

To create a meaningful plot or if you want to save your plot as image you may want to define a fix aspect ratio. The plot function itself offers the possibility to define an own aspect ratio by setting the asp property. By default this property is ‚0‘ and therefore disabled.

The following example shows some plots with the same sinus function but different aspect ratios.

par(mfrow=c(2,3))
x <- seq(0, 20, 0.2)
y <- sin(x)

plot(x,y, type=’l‘, main=’ratio = 0′, asp=0)
plot(x,y, type=’l‘, main=’ratio = 1′, asp=1)
plot(x,y, type=’l‘, main=’ratio = 2′, asp=2)
plot(x,y, type=’l‘, main=’ratio = 4′, asp=4)
plot(x,y, type=’l‘, main=’ratio = 6′, asp=6)
plot(x,y, type=’l‘, main=’ratio = 8′, asp=8)

R27

Werbung
Dieser Beitrag wurde unter R veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit deinem WordPress.com-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s