0

I have the following data:

set.seed(1)
df <- data.frame(ID = c(1:123), 
                 value = rnorm(123, mean = 30))

and I prepare the plot

ggplot (df) +
  geom_rect(aes(xmin = 0, xmax = 100, ymin = 28.4, ymax =31.6), 
            fill = "lightcoral", alpha = 0.006) +
  geom_point(aes(x=ID, y = value), color = "red3") 

How to determine (calculate) y min and y max so that 80% of the points are in the middle of the area? Of course, an area may contain 98 points (in this example).

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
GrBa
  • 381
  • 1
  • 9
  • You seem to want to show 2D probabilities. I think you probably may rather want to use 2d density contours. – tjebo Jul 16 '20 at 11:10
  • There is some discussion on this topic on SO. See for example https://stackoverflow.com/questions/59507974/calculate-probability-of-value-based-on-2d-density-plot-in-r or https://stackoverflow.com/q/61817440/7941188 or https://stackoverflow.com/q/19329318/7941188 – tjebo Jul 16 '20 at 11:13

0 Answers0