Consider the two following plots:
x <- rnorm(1000, sd=10)
plot(density(x))
plot(ecdf(x))
Please note the different y-axis ranges:
Now I would like to have these two in one graph and two y-axis.
I know the basics (add=TRUE
, or par(new=TRUE)
), but add=TRUE
does not work due to the different scales, par(new=TRUE)
requires specifying a x-axis to avoid over plotting.
Is there an easy way of getting these two into one graph, left y-axis density, right y-axis ecdf?