Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ribbon plots #46

Merged
merged 3 commits into from
Jul 25, 2023
Merged

Support ribbon plots #46

merged 3 commits into from
Jul 25, 2023

Conversation

grantmcdermott
Copy link
Owner

Closes #25

(Also fixes some lingering issues with the "pointrange" and "errorbar" types w.r.t. numeric intervals.)

@grantmcdermott
Copy link
Owner Author

@vincentarelbundock This might interest you. marginaleffects example:

library(marginaleffects)
dat = palmerpenguins::penguins

mod = lm(bill_length_mm ~ flipper_length_mm * species, data = dat)
pre = predictions(
    mod,
    newdata = datagrid(
        flipper_length_mm = fivenum,
        species = unique
    )
)

library(plot2)
par(las = 1)

 with(
     pre,
     plot2(
         x = flipper_length_mm, y = estimate,
         ymin = conf.low, ymax = conf.high,
         by = species,
         type = "ribbon",
         palette = "harmonic",
         frame = FALSE, grid = TRUE
     )
 )

Created on 2023-07-25 with reprex v2.0.2

(One nagging issue is that the default legend doesn't allow you to easily combine filled rectangles with lines. So right now we just keep the lines when a legend is printed. See Roman's solution here in case we decide to shipped our own, slightly modified legend2 function.)

@grantmcdermott grantmcdermott merged commit c5c9a04 into main Jul 25, 2023
5 checks passed
@grantmcdermott grantmcdermott deleted the ribbon branch July 25, 2023 14:31
@vincentarelbundock
Copy link
Collaborator

Oooh, this is suuuper neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wishlist: pointrange and ribbons
2 participants