Skip to content

plot_violin and plot_boxplot of not the same colour #6240

Closed
@sunta3iouxos

Description

@sunta3iouxos

There is a discrepancy of what I am expecting and what I am seeing in the plot:

I expected bot the box and violin plot to have the same fill colour as dictated by the first aes in ggplot

Here is the code to reproduce the bug:
table:

                ENSEMBL SYMBOL      variable    value   group
1    ENSMUSG00000000202 Btbd17 Control24R9_1 109.1046 Control
518  ENSMUSG00000000202 Btbd17 Control24R9_2 166.6350 Control
1035 ENSMUSG00000000202 Btbd17 Control24R9_3 159.1631 Control
1552 ENSMUSG00000000202 Btbd17 Control24R9_4 151.6898 Control
2069 ENSMUSG00000000202 Btbd17 Control24R9_5 213.5611 Control
2586 ENSMUSG00000000202 Btbd17   High24R9_11 419.3453    High
3103 ENSMUSG00000000202 Btbd17   High24R9_12 517.9035    High
3620 ENSMUSG00000000202 Btbd17   High24R9_13 480.5555    High
4137 ENSMUSG00000000202 Btbd17   High24R9_14 479.2452    High
4654 ENSMUSG00000000202 Btbd17 Medium24R9_10 382.6466  Medium
5171 ENSMUSG00000000202 Btbd17  Medium24R9_6 254.7115  Medium
5688 ENSMUSG00000000202 Btbd17  Medium24R9_7 434.6238  Medium
6205 ENSMUSG00000000202 Btbd17  Medium24R9_8 297.2700  Medium
6722 ENSMUSG00000000202 Btbd17  Medium24R9_9 433.5102  Medium

code:

ggplot(data, aes(x = SYMBOL, y = value, fill = as.factor(group)), group = interaction(SYMBOL,group)) +
  geom_violin(width=0.75, alpha=0.3) +
  scale_fill_manual(values = c("lightgreen", "red", "blue")) + 
  geom_boxplot(width=0.75, color="darkgrey", alpha=0.9, outlier.size = 0, outlier.shape = NA) +
  geom_point(position = position_jitterdodge(jitter.width	= 0.3,dodge.width = 0.75)) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1))

what I am getting:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions