Reputation: 41
I have three groups (Tissue) and two groups (Treatment) represented in a faceted boxplot. I would like to remove the legend for "Treatment", as it is already represented in the graph, and keep the legend for "Tissue".
box <- ggboxplot(subclusDF,
x = 'Treatment',
y = 'ATP4',
fill = "Tissue",
color = 'Tissue',
palette = qualitative_hcl(3, palette = 'Dark 3'),
add = 'jitter',
shape = 'Treatment')
box <- box +
labs(title= 'GHRL') +
xlab(NULL) +
ylab("Expression") +
facet_grid(~Tissue)
box
box +
theme() +
theme(
plot.title = element_text(face = "bold", size = 12),
legend.background = element_rect(fill = "white", size = 4, colour = "white"),
legend.justification = c(0, 1),
legend.title=element_text(NULL),
legend.key = element_blank(),
legend.position = c(0, 1),
axis.text = (NULL),
axis.ticks = element_line(colour = "grey70", size = 0.2),
panel.grid.major = element_line(colour = "grey70", size = 0.2),
panel.grid.minor = element_blank()
)
box
Upvotes: 3
Views: 5277
Reputation: 142
So, specifically you'd want to remove the legend for shape:
box +
guides(shape = "none")
Upvotes: 2