Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does abline shows on the opposite side on kernel density plots?

I’m curious why the vertical line is showing at -10 and not 10 in the following example:

x <- rnorm(1e4, 0, 10)
plot(density(x))
abline(10, 1, col = "red")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What you need is using h=10 instead of a=10, b=1. From the helpfile you can read:

h the x-value(s) for vertical line(s).

So, to produce your desired output use the following:

abline(v=10, col = "red")

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading