[R] How to show a specific value of a ggplot2

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Fri May 27 07:49:42 CEST 2022


Hello,

If you cannot determine the exact value of y for given x, then isn't 
your problem how to determine an approximate value of y? Once you have 
it, it's easy to plot it.

With newdata = data.frame(x = 75, y = ???),


ggplot(mydata, mapping = aes(x, y)) +
   geom_point(color = "black") +
   geom_point(newdata, mapping = aes(x, y), color = "red") +
   xlim(0, 200)


The question is how to find newdata$y, interpolation, other method?

Hope this helps,

Rui Barradas

Às 00:40 de 27/05/2022, Neha gupta escreveu:
> I have a ggplot2 which has x-values 0-200 and y values 0-10
> 
> p=plot(mydata)
> p+xlim(0, 200)
> 
> I want to show what is the y value when we have 75 as x value. The graph
> which is displayed has a broad range (like 0-50, 50-100 etc on x axis) and
> cannot determine the exact value of y at the value of 75 on x-axis.
> 
> Thank you
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org 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.



More information about the R-help mailing list