Reputation: 63
I created a swimmer plot using package swimplot and added response lines to the graph, but the legend symbols have borders that I cannot figure out how to remove.
swimmer_lines(
df_lines = resp, id = "study_id", start = "response_start",
end = "response_end", name_col = "response", size = 1
) +
scale_color_manual(
name = "Response",
values = c("PD" = "red", "SD" = "grey", "PR" = "mediumpurple", "CR" = "violetred1"),
breaks = c("PD", "SD", "PR", "CR")
) +
guides(color = guide_legend(override.aes = list(fill = NA)))
How can I remove the "borders" on each of the legend symbols without removing the line/legend symbol itself?
Upvotes: 1
Views: 240
Reputation: 174468
You didn't include the code for your base swimplot, but if you only want the lines in the legend, you could do:
library(swimplot)
library(ggplot2)
swimmer_plot(df = resp, id = "study_id", start = "response_start",
end = "response_end", name_col = "response", size = 1, fill = NA,
color = NA) +
swimmer_lines(resp, id = "study_id", start = "response_start",
end = "response_end", name_col = "response", size = 1) +
scale_color_manual(name = "Response",
values = c("PD" = "red", "SD" = "grey", "PR" = "mediumpurple",
"CR" = "violetred1"),
breaks = c("PD", "SD", "PR", "CR"))
Created on 2023-01-03 with reprex v2.0.2
Data used
In the absence of a reproducible example, here is a data frame with the same characteristics as the OP's, inferred from the supplied code:
resp <- data.frame(study_id = c("A", "B", "C", "D"),
response_start = 1:4, response_end = 4:7,
response = c("PD", "SD", "PR", "CR"))
Upvotes: 1