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

docs: Add example of how to create polar bar charts #3428

Merged
merged 1 commit into from
Jun 28, 2024
Merged

Conversation

joelostblom
Copy link
Contributor

I was playing around a bit and thought this was a potentially useful example of how to do something that is not immediately obvious when reading the arc_mark docs. In many other contexts these are referred to as "polar bar charts" so I chose that name to show that it is possible to create these in altair, although we are not technically supporting a polar coordinate system.

image

@joelostblom joelostblom changed the title doc: Add example of how to create polar bar charts docs: Add example of how to create polar bar charts May 30, 2024
@mattijn
Copy link
Contributor

mattijn commented May 30, 2024

Maybe add the name "rose plot" to it as well.
I did a section on this at the geopython conference last year, see also onwards from here: https://mattijn.github.io/posts/2023-03-07-talk-geopython-2023/#interaction

@joelostblom
Copy link
Contributor Author

Nice post @mattijn ! Could you link me to where you defined the function utils_chart_rose()? Maybe I can borrow something from there to improve this example as well

@jonmmease
Copy link
Contributor

Great example @joelostblom! Someday it would be great to have the logic for creating the polar guide included in a package somewhere. Either in Vega-Altair itself or an altair-polar package or something. We could probably also support points and lines in polar coordinates as well.

@mattijn
Copy link
Contributor

mattijn commented May 31, 2024

Could you link me to where you defined the function utils_chart_rose()?

Its here: https://github.com/mattijn/talks/blob/main/docs/utils_geoconf_23.py#L35. Totally agree with @jonmmease that better support for this is welcome as there is currently no any automated axis positioning.

eg. sometimes these polar bars are not starting at zero, but has the middle line of the bar at zero, then you can use a theta offset as such alt.Chart().mark_arc(thetaOffset=np.deg2rad(-7.5)).encode(..) to accommodate for this.

@mattijn mattijn merged commit 54a68a3 into main Jun 28, 2024
21 of 22 checks passed
@mattijn
Copy link
Contributor

mattijn commented Jun 28, 2024

Its good enough already for now! Thanks @joelostblom!

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

Successfully merging this pull request may close these issues.

3 participants