I built a plot in R that contains 3 different violin plots. I want to add 3 different horizontal lines so that in the first plot is at y = 0.44, in the second plot at y = 0.413 and in the third plot at y = 0.375. Something like the red dots on this image.
I tried using “geom_hline” but did not work because I could not find a way to select the values of x since my x axis is not composed of continuous variables
This is the current code I use to build the plots:
library(tidyverse)
library(modeldata)
?geom_boxplot
data <- read.csv("Qualtrics.csv", TRUE, ";")
ggplot(data, aes(x = factor(Problem,level = c("Disease", "Cab", "Course")), y = Estimate, fill = Problem)) + geom_violin(fill = "lightgray") + geom_boxplot(width = .02, fill= "black") + xlab("Problems")
Joao Queiroz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.