jamovi / jmv

jamovi for R
https://www.jamovi.org
55 stars 27 forks source link

Make the plots more jittery? #404

Open giladfeldman opened 1 month ago

giladfeldman commented 1 month ago

Hi,

JAMOVI creates some great plots, but some of those with the dots just look like they're on a line.

I'm guessing there's something that I can do to make those dots jitter more with ggplot2? Any help or guidance would be appreciated.

Example: 3-reasons-mixed-anova

The code that creates this plot:

jmv::anovaRM(
    data = s2plot,
    rm = list(
        list(
            label="Reasons",
            levels=c("Waste", "Emotions", "Value", "Past"))),
    rmCells = list(
        list(
            measure="study2_reason_min_waste",
            cell="Waste"),
        list(
            measure="study2_reason_min_neg_emo",
            cell="Emotions"),
        list(
            measure="study2_reason_max_value",
            cell="Value"),
        list(
            measure="study2_reason_consistent_previous",
            cell="Past")),
    bs = Condition,
    effectSize = c("eta", "partEta"),
    depLabel = "Importance",
    rmTerms = ~ Reasons,
    bsTerms = ~ Condition,
    spherTests = TRUE,
    spherCorr = c("GG", "HF"),
    postHoc = list(
        c("Reasons", "Condition"),
        "Reasons"),
    emMeans = ~ Reasons + Condition + Reasons:Condition,
    emmTables = TRUE,
    emmPlotData = TRUE)

How might I tweak that? I tried looking at s2plotjmv$emm[[3]]$emmPlot$plot but wasn't sure what kind of plot that is. Doesn't look like a ggplot2 I could add "+ geom_jitter()" to, is it?

Not a must and not a big deal, but can maybe add an argument to the JMV functions resulting in plots, or add something to the documentation. And, for those using this package in JAMOVI, maybe even an option to play around with things like the jitter (height/width/etc.)

raviselker commented 4 weeks ago

Hi!

You can have access to the ggplot2 object through the s2plotjmv$emm[[3]]$emmPlot$plot$fun() function, so if you assign this to a variable than you should be able to use it as any other ggplot2 object.

However, though it's easy to adjust some theming this way, it's probably a lot harder to change an already created geom within the plot so not sure how you would change the jitter this way.

giladfeldman commented 4 weeks ago

Hi Ravi, thank you. Learned something new about extracting the ggplot2 object from jmv, but yeah, you're right, can't jitter it that way, unfortunately.

JAMOVI team: Might it be possible to add to JMV functions a way of tweaking the plots with an argument so that we can add better jitter?