Search code examples
rcolorsboxplot

change siberDensityPlot colors by group


I am using the SIBER package to develop a plot with three groups, I would like to color each group according to a legend. The SIBER pdf says to use the clr command, which states that

"a matrix of colours to use for shading each of the box regions. Defaults to greyscale grDevices::gray((9:1)/10) replicated for as many columns as there are in dat. When specified by the user, rows contain the colours of each of the confidence regions specified in probs and columns represent ecah of the columns of data in dat. In this way, one could have shades of blue, red and yellow for each of the groups."

However, if you run the code on a help website (https://rdrr.io/cran/SIBER/man/siberDensityPlot.html) to get a "colorful" plot instead of the greyscale plot, with the matrix of colors as specified:

# A basic default greyscale density plot
Y <- matrix(stats::rnorm(1000), 250, 4)
siberDensityPlot(Y)

# A more colourful example
my_clrs <- matrix(c("lightblue", "blue", "darkblue",
"red1", "red3", "red4",
"yellow1", "yellow3", "yellow4",
"turquoise", "turquoise3", "turquoise4"), nrow = 3, ncol = 4)
siberDensityPlot(Y, clr = my_clrs)

The result is NOT one boxplot with three shades of blue representing each CI, then another with red shades, yellow shades, etc...you create a plot with 3 shades of blue for each CI repeated across all of the different "groups" or boxplots in the panel.

My question is: does anyone know how to make the graphic so that you get shades of color in the boxplot representing different CIs, then a different color with shades for CIs for another group? The figure attached will hopefully further explain what I am trying to accomplish.

enter image description here


Solution

  • It looks like some type of bug. I see that the link you posted produced the all blue plot, but when I run the code on my PC I get this plot. I'm running Windows 10 R version 4.0.2 with the latest SIBER package from CRAN. The link is running linux and R 3.4.4 it seems. enter image description here