-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Description
When boxplotSubarray() is used without specifying a color variable, a "dangling" legend is produced on the top of the plot. "Dangling" here refers to a legend with only 1 color category (i.e. an uninformative legend). By default, the legend title is removed, so only the box icon is displayed. This shrinks the overall size of the boxplot area (to accommodate the legend), and results in an unclean final plot. The ultimate goal of this package is to produce out-of-the-box, polished figures for SomaScan, and this unused legend would need to be trimmed off of any final figure.
I think this issue stems from the use of a dummy variable for the fill argument of ggplot(). When fill= or color= is specified, a legend is produced by default. In the example below, "class" is a dummy variable that contains no grouping information and is generated and added to plot_data when boxplotSubarray(..., color.by=NULL):
p <- plot_data |>
ggplot(aes(x = as.character(.id), y = RFU_values, fill = class)) +
geom_boxplot(notch = TRUE, alpha = 0.75, outlier.alpha = 0.2) +
scale_fill_soma() +
NULLNote: this is not an urgent issue, because boxplotSubarray() is typically used with a column specified for the color.by= argument. However, when using the default (color.by=NULL), this uninformative legend is produced.
Output
reprex::reprex(
SomaPlotr::boxplotSubarray(SomaDataIO::example_data, color.by = NULL)
)Priority Level
- High
- Medium
- Low
Thanks for reporting 🥳!