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

Allow absolute width for geom_errorbar (and possibly others) #1288

Open
marcpabst opened this issue Jan 21, 2025 · 5 comments
Open

Allow absolute width for geom_errorbar (and possibly others) #1288

marcpabst opened this issue Jan 21, 2025 · 5 comments
Labels
Milestone

Comments

@marcpabst
Copy link

Currently, the width argument for geom_errorbar only sets the relative size of the whiskers. It would be really helpful to have an option to specify the whisker size in absolute units. This would make it easier to maintain consistent whisker dimensions across plots, regardless of the scale or data range.

@alshan
Copy link
Collaborator

alshan commented Jan 22, 2025

We maybe can have an additional parameters width_unit and height_unit. Or just one cap_unit, accepting "px" or "lw":

geom_errorbar(width = 5, cap_unit = "px")   # 5 pixels
geom_errorbar(width = 3, cap_unit = "lw")   # 3 * linewidth

Would it do?

@marcpabst
Copy link
Author

I think that would be helpful. My main use case are plots with a varying of discrete data points on the x axis, which look weird with uber-long whiskers. If I remember correclty, Makie.jl does something similar, where you can specify the reference frames for x and y values independently, which comes in very handy sometimes.

@alshan
Copy link
Collaborator

alshan commented Jan 22, 2025

Ok, and you've mentioned "and possibly others" in the title. Are you referring to boxplot?

@alshan
Copy link
Collaborator

alshan commented Jan 22, 2025

Interesting, there is whisker_width parameter in geom_boxplot

Same in geom_errorbar could work as well I guess.

@marcpabst
Copy link
Author

geom_boxplot, and possibly even geom_bar()? Basically, everything where there is a width parameter, and one could reasonably want to specify the size in absolute units (although I'm admittedly struggling to come up with a good use case for geom_bar()). Another related thing is specifying absolute units for something like geom_label(), which I often use for annotations but currently can only be specified in data coordinates. Maybe it's worth finding a more general solution to this?

Here's what Makie.jl is doing: https://docs.makie.org/v0.22/explanations/conversion_pipeline#Coordinate-spaces

@alshan alshan added this to the New milestone Jan 23, 2025
@alshan alshan added the * label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants