njudd / ggrain

{package} Make beautiful Raincloud plots in R!
Other
67 stars 4 forks source link

Space between boxplots not overlapping #10

Closed bcuer closed 9 months ago

bcuer commented 9 months ago

Hello,

Thnak you for your remarkable package very useful 👍.

I would like to reproduce a graph from the package's vignette using the following code:

ggplot(iris, aes(1, Sepal.Width, fill = Species, color = Species)) +
    geom_rain(alpha = .5, rain.side = 'l',
              boxplot.args = list(color = "black", outlier.shape = NA),
              boxplot.args.pos = list(
                  position = ggpp::position_dodgenudge(x = .1), width = 0.1
              )) +
    theme_classic() +
    scale_fill_brewer(palette = 'Dark2') +
    scale_color_brewer(palette = 'Dark2') +
    guides(fill = 'none', color = 'none')

It produces the following plot:

Rplot

Unfortunately, the result differs significantly from what is shown in the vignette. Specifically, the boxplots appear to be widely spaced, unlike the compact arrangement depicted in the vignette. I am unsure of the parameter adjustments needed to address this discrepancy.

For your information, I used to work with R version 4.1.2, and the generated graphics were accurate. However, after recently updating to the latest R version (4.3.2), I've observed that certain types of graphs are no longer reproducible.

Thank you for any suggestions or improvements. Benjamin

lusemp commented 9 months ago

Hi

I experience the same issue while using the f2x2 notation.

geom_rain(alpha = .5, rain.side = 'f2x2', id.long.var = "ID", violin.args = list(color = NA, alpha = .5), show.legend = FALSE)

Thanks for any ideas how to solve it. cheers, Lukas

njudd commented 9 months ago

Are you guys using Windows? I can't seem to replicate the error with R 4.3.2 on mac @jorvlan can you see if you can replicate this issue (even just on mac)?

lusemp commented 9 months ago

I use mac and R 4.3.2 and could replicate the issue. It only started occurring after I updated multiple packages.

Screenshot 2024-01-19 at 07 21 08
lusemp commented 9 months ago

I tracked the error to the ggpp package. Using version ggpp 0.5.5 everything works but with ggpp 0.5.6 the issue occurs.

bcuer commented 9 months ago

Indeed, by using version ggpp 0.5.5, it works. A solution to achieve this:

install.packages("remotes")
library(remotes)
remove.packages("ggpp")
install_version("ggpp", "0.5.5")

library(ggrain)

ggplot(iris, aes(1, Sepal.Width, fill = Species, color = Species)) +
    geom_rain(alpha = .5, rain.side = 'l',
              boxplot.args = list(color = "black", outlier.shape = NA),
              boxplot.args.pos = list(
                  position = ggpp::position_dodgenudge(x = .1), width = 0.1
              )) +
    theme_classic() +
    scale_fill_brewer(palette = 'Dark2') +
    scale_color_brewer(palette = 'Dark2') +
    guides(fill = 'none', color = 'none')

The plot is generated successfully: Rplot

Thank you very much for your help.

njudd commented 9 months ago

Thanks for isolating it, just re-opening the issue until I fix it! Will figure out what is going on with the new version of gppp :)

njudd commented 9 months ago

The latest version of ggrain 0.0.4 should solve this issue. I will keep it open until I update it on CRAN.

To get the latest version:

if (!require(remotes)) {
    install.packages("remotes")
}
remotes::install_github('njudd/ggrain')
library(ggrain)

The solution is quite simple, width needs to be given twice now with ggpp 0.5.6.

previously: boxplot.args.pos = list(position = ggpp::position_dodgenudge(x = .1), width = 0.1)

ggpp 0.5.6: boxplot.args.pos = list(position = ggpp::position_dodgenudge(x = .1, width = 0.1), width = 0.1)

Thanks a million for identifying that it was ggpp, saved a bunch of time!

njudd commented 9 months ago

Fixed in version 0.0.4; when installing ggrain choose 1 'update all packages'.