Reputation: 1
Just wanting to add a custom palette to this visualization. I have tried adding it manually using palette = c("colour1", "colour2",...) and using custom_palette. Nothing is working. Is there a way to extract this data and run it in ggplot2?
Here is the code I am working with: #Multi-group analysis in dabestr
multi_groups <- load(data, x = Treatment, y = Total_CO2,
idx = list(
c("GB-L", "LDPE-L"),
c("GB-H", "LDPE-H"),
c("GF-L", "PA-L"),
c("GF-H", "PA-H") ))
print(multi_groups)
multi_groups.mean_diff <- mean_diff(multi_groups)
print(multi_groups.mean_diff)
multi_groups.mean_diff
#Plots
dabest_plot(multi_groups.mean_diff) <--- THIS IS WHERE I WANT TO CHANGE THE COLOUR PALETTE
dabest_plot(multi_groups.mean_diff, palette = c("colour1", "colour2"... etc) - did not change the colours
Upvotes: 0
Views: 179
Reputation: 174468
If you look at the documentation for ?dabest_plot
, you will see that it only describes two named arguments, neither of which control the color, but the function also allows extra arguments to be passed via ...
.
...
Adjustment parameters to control and adjust the appearance of the plot. (list of all possible adjustment parameters can be found under plot_kwargs)
We therefore need to look up the documents for ?plot_kwargs
to find out how to control the color palette. Here we find that there is an argument called custom_palette
:
custom_palette
Default "d3". String. The following palettes are available for use: npg, aaas, nejm, lancet, jama, jco, ucscgb, d3, locuszoom, igv, cosmic, uchicago, brewer, ordinal, viridis_d.
Essentially, these are the palettes you are stuck with. Although the final object produced by the dabest_plot
function is a ggplot object, it is actually a cowplot
type ggplot, meaning one cannot simply add new color and fill scales to it.
To be fair, there are several palettes to choose from, all of which give quite a professional look.
Here's an example:
library(dabestr)
dabest_obj <- load(non_proportional_data,
x = Group, y = Measurement,
idx = c("Control 1", "Test 1", "Test 2", "Test 3"))
dabest_obj.mean_diff <- mean_diff(dabest_obj)
dabest_plot(dabest_obj.mean_diff, TRUE)
And here with a different palette:
dabest_plot(dabest_obj.mean_diff, TRUE, custom_palette = "igv")
From looking at the code of the package, it doesn't look as though it would be terribly difficult to add in a fully customizable palette, but it seems that this is not a priority for the authors right now.
Upvotes: 2