-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature request: New geom_dash()
#6430
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
Comments
I have wanted something like this for a long time. (Even wrote my own, but then flaked out and never put it anywhere where it could be reused.) I think ggforce would be a better place for it though. |
I thought this was such a basic and commonly used geom when plotting continuous vs. categorical data that it might even be built into ggplot2 itself. |
Thanks for the suggestion Broder! I agree that this is useful and definitely should live somewhere. After a cursory rummage through existing extensions I couldn't quickly find something similar. I'm a bit torn between 'it should live in ggplot2' and 'it should live in an extension package'. On the one hand, yes this is useful in a pretty broad way. On the other hand, a policy that ggplot2 has is that it tries to take on as little as possible additional geoms and stats (other than meta-functionality). I'll discuss with Thomas after Easter. |
Thanks for considering! |
Related: I think you need both horizontal and vertical lines. |
I have no problems just removing duplicate and empty lines from |
To me the issue with |
I think this describes what I did. I took
|
Thus, it now only requires |
I've discussed this with Thomas and the consensus was that we feel this would be a good fit for an extension package. You're absolutely free to build one yourself, but if you feel that is too much work, ggforce would also work (if Thomas ever gets around reviewing PRs 😁) |
I still believe it would be great to see this integrated into ggplot2 someday—perhaps in an alternative future, or simply ten years down the line 😅 Thank you as well for suggesting ggforce as a potential home. I have recently been exploring the ggplot2 extension mechanisms more deeply, so I suppose time will tell whether I end up with a random bunch of geoms—or something I would actually feel comfortable calling a proper package. That said, the reach of such a standalone package would likely be quite limited, so there is definitely a strong case for ggforce. I will take some time to figure this out. In any case, thank you again for considering it! |
Hi Teun!
Measures of central tendency—like the mean or median—are often visualized using a horizontal dash. To my knowledge, this is not easily done in current ggplot2. Some workarounds exist, such as using
geom_errorbar()
in creative ways. However, this approach stacks several lines on top of each other. It also requires a good understanding of how to tweakstat_summary()
. Overall, current options feel unnecessarily clunky to me.https://stackoverflow.com/questions/59018229/adding-a-dashed-line-to-mark-the-mean-in-ggplot
Therefore, I drafted a new
geom_dash()
, which you can see in action below. In case this would be of interest, I could provide a PR to be used as a starting point.The text was updated successfully, but these errors were encountered: