Did you know that you can navigate the posts by swiping left and right?

Plotting distributions

29 Apr 2016 . category: R . Comments
#R #Plots

In case you need to plot distributions using R, the following code should do the trick.

plot(function(x) dnorm(x, 30, 15), -20, 80, ylab="Density", xlab="Size", col="dark green", lwd=2)

if for some reason you need to change the scale of the x axis:

plot(function(x) dnorm(x, 30, 15), -20, 80, ylab="Density", xlab="Size", col="dark green", lwd=2, xaxt="n")

axis(side=1, at=seq(-20,80,20), labels=(seq(-20,80,20)))

the sequences used for at and labels need to be of the same lenght.


Me

Sergio Vargas. Assistant professor at the LMU München. Working with octocorals, sponges and cyanobacteria.