'Label Coordinates in ggplot 2 in R [closed]
I have drawn a cumulative distribution graph in R. I want to label the points on the graph when the Y-axis (Cumulative probability) has 0.1, 0.2, 0.3...etc (some specific Y values) with both X and Y coordinates. For example, I want to mark the point (1250,0.5) in the graph and labelthat value in the graph. I would appreciate it if you could help me.
Solution 1:[1]
You need to add points using a separate geom_point function.
library(tidyverse)
theme_set(theme_minimal())
# Loading data
iris = as_tibble(iris)
Now I filter points that I want to highlight.
# filter out points to highlight (say which have sepal.length 5, 4.4 or 4.9)
iris_highlight = iris %>%
filter(Sepal.Length %in% c(5.0, 4.4, 4.9))
Now comes the meat.
# Plot
iris %>%
ggplot(aes(x = Sepal.Width, Sepal.Length)) +
geom_point(alpha = 0.3) +
geom_point(data = iris_highlight,
aes(x = Sepal.Width, y = Sepal.Length, colour = "red"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Harshvardhan |


