Add a vertical line and some values on a plot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Add a vertical line and some values on a plot

R help mailing list-2
Dear R-experts,

Here below is my code,
I would like to add a vertical line on my plot, showing the median and I would like to place some values on this graph as well, i.e. 4.3 and -8.4. How can I do ?
Many thanks for your reply.



A=c(1,2.3,4,3.5,4.3,2.5,6.3,-0.1,-1.5,3.7,-2.3,-3.5,5.4,3.2, -10.5,-8.4,-9.4)
d <- density(A)
plot(d)
median(A)

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Add a vertical line and some values on a plot

Rui Barradas
Hello,

After the plot just do

abline(v = median(A))

As for how to plot points, see, well, ?points().

Hope this helps,

Rui Barradas

Em 22-10-2017 16:33, varin sacha via R-help escreveu:

> Dear R-experts,
>
> Here below is my code,
> I would like to add a vertical line on my plot, showing the median and I would like to place some values on this graph as well, i.e. 4.3 and -8.4. How can I do ?
> Many thanks for your reply.
>
>
>
> A=c(1,2.3,4,3.5,4.3,2.5,6.3,-0.1,-1.5,3.7,-2.3,-3.5,5.4,3.2, -10.5,-8.4,-9.4)
> d <- density(A)
> plot(d)
> median(A)
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Add a vertical line and some values on a plot

R help mailing list-2
Hi Rui,


Many thanks for your response.




________________________________
De : Rui Barradas <[hidden email]>

roject.org>
Envoyé le : Dimanche 22 octobre 2017 18h27
Objet : Re: [R] Add a vertical line and some values on a plot



Hello,

After the plot just do

abline(v = median(A))

As for how to plot points, see, well, ?points().

Hope this helps,

Rui Barradas


Em 22-10-2017 16:33, varin sacha via R-help escreveu:

> Dear R-experts,
>
> Here below is my code,
> I would like to add a vertical line on my plot, showing the median and I would like to place some values on this graph as well, i.e. 4.3 and -8.4. How can I do ?
> Many thanks for your reply.
>
>
>
> A=c(1,2.3,4,3.5,4.3,2.5,6.3,-0.1,-1.5,3.7,-2.3,-3.5,5.4,3.2, -10.5,-8.4,-9.4)
> d <- density(A)
> plot(d)
> median(A)
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.