I’m working on a plot that displays y values based on x categories and the medians associated. Here’s the code:
Plot_RM <- ggplot(test_data) +
aes(EX_ABS, RM_ABS)+
geom_bar(stat = "identity")+
geom_text(aes(label = RM_ABS), position = position_stack(vjust = 0.75))+
geom_point(aes(x = EX_ABS, y = RM_MED), shape = "u1397",color = "red")+
labs(title = "Rapport des 1 RMs absolus (kg)",
y = "RM (kg)",
x = "Exercices")+
theme(panel.background = element_rect(fill = "white"),
panel.grid = element_blank(),
legend.position = "bottom",
axis.text.x = element_text(angle = 45,
vjust = 1,
hjust = 1,
size = 8),
plot.title = element_text(size = 20),
axis.text.y = element_text(size = 8),
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
text = element_text(family = "copperlight"))
The goal is to add a “line” representing each X category’s medians.
Here’s my dataset:
dput(test_data)
structure(list(Masse = c(125.6, 125.6, 125.6, 125.6, 125.6, 125.6,
125.6, 125.6, 125.6, 125.6, 125.6), Nom = c("Tikoipau", "Tikoipau",
"Tikoipau", "Tikoipau", "Tikoipau", "Tikoipau", "Tikoipau", "Tikoipau",
"Tikoipau", "Tikoipau", "Tikoipau"), Postes = c("PILIER", "PILIER",
"PILIER", "PILIER", "PILIER", "PILIER", "PILIER", "PILIER", "PILIER",
"PILIER", "PILIER"), EX_ABS = structure(1:11, levels = c("DC",
"DM", "Trac", "Dips", "SQT", "FSQT", "SDT", "EPAU", "PP", "JETE",
"ARRAC", "DIST_MAX_ABS"), class = "factor"), RM_ABS = c(145,
NA, 266, NA, 204, NA, NA, 134, 125, NA, NA), RM_REL = c(1.15,
NA, 2.11, NA, 1.62, NA, NA, 1.07, 1, NA, NA), RM_MED = c(145,
80, 266, 118, 172, NA, 190, 109, 114, NA, NA)), row.names = c(NA,
-11L), class = c("tbl_df", "tbl", "data.frame"))
I tried to set up this with a geom_hline but the lines cross the entire plot. I prefer to use a geom_point with a different shape such as a “line” shape corresponding to “u1397”. However, when I print my plot I’ve got a little crossed rectangle which, I supposed, is similar to “NA” but for plots.
However, when running “u1397” into my console it works.I don’t understand the issue, may someone help me?
gerard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.