Good afternoon everyone.
I have an issue with producing an appropriate legend in my ggplot2
boxplot. Unfortunately, after adding scale_linetype_manual('Legend',values='solid')+ scale_shape_manual('',values = 18)+ theme(legend.spacing.y = unit(0.01, "cm"))
to my line codes, it does not produce the legend at all. I have been trying to add legend in many different ways, but none of them seemed to work.
This is the entire code to produce the following graphs
PhospholipaseA2NOPo1<-structure(list(Drug = structure(c(1L, 1L, 5L, 5L, 5L, 5L, 5L,
5L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L,
2L, 2L, 2L), .Label = c("Blank", "SP.N", "SP.V", "V.N", "V.V"
), class = "factor"), Absorbance = c(0.178155098, 0.281888047,
0.315468607, 0.395427286, 0.443773761, 0.274327232, 0.126408569,
0.160375886, 0.332019768, 0.328779358, 0.31918001, 0.202597307,
0.241052828, 0.332138474, 0.356656925, 0.329787758, 0.291912398,
0.264823437, 0.167194165, 0.176451481, 0.406376062, 0.28900749,
0.298281464, 0.181890255, 0.245723697, 0.350279692)), class = "data.frame", row.names = c(NA,
-26L))
library(tidyverse)
library(ggplot2)
library(ggpubr)
library(RColorBrewer)
ggplot(PhospholipaseA2NOPo1, aes( x = Drug, y = Absorbance))+
labs(x = expression(paste("Treatment")))+
ylab(expression(paste("Absrobance " ~ "(", A[425], " - ", A[600] ~ nm, ")"))) +
geom_line()+
labs(title = "Comparison of the effect of Blank, Vehicle - Vehicle, Vehicle - Nicotinic Acid, SP - Vehicle, and SP - Nicotinic Acid on microglia ",
caption = "Phospholipase A2 Assay")+
geom_point() +
scale_x_discrete(labels = c("Blank", "Vehicle- Vehicle", "Vehicle - Nicotinic Acid", "SP - Vehicle", "SP - Nicotinic Acid"))+
stat_compare_means(label.y = 0.80,
label.x = 4.25)+
geom_boxplot(
fill=c("#B2182B", "#D6604D", "#F4A582", "#FDDBC7", "#D1E5F0"),
width=0.2,notch = FALSE)+
stat_summary(fun=mean, colour="black", geom="point",
shape=18, size=3) +
geom_signif(comparisons = split(t(combn(levels(PhospholipaseA2NOPo1$Drug), 2)), seq(nrow(t(combn(levels(PhospholipaseA2NOPo1$Drug), 2))))),
map_signif_level = TRUE, colour = "#cf1b1b", step_increase = .1)+
theme_bw() +
theme(panel.grid.major = element_line(colour = "#d3d3d3"),
panel.grid.minor = element_blank(),
panel.border = element_blank(), panel.background = element_blank(),
plot.title = element_text(size = 14, face = "bold"))+
theme(axis.text.x = element_text(face="bold", color="#3142b0",
size=8.9, angle=0),
axis.text.y = element_text(face="bold", color="#3142b0",
size=8.9, angle=0))+
theme(
plot.title = element_text(size = 12, face = "bold"),
plot.caption = element_text(hjust = 0, size = 8, face = "italic")
)+
scale_linetype_manual('Legend',values='solid')+
scale_shape_manual('',values = 18)+
theme(legend.spacing.y = unit(0.01, "cm"))
And this is the DataUsed
Thank you so much for any help!