Repository navigation
Add treemaps #854
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
Merged
Merged
Add treemaps #854
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4cc15d5
add treemaps
cvanelteren a3ae7a6
Move treemap defaults to rc settings and add type annotations
cvanelteren 3f906a2
Simplify treemap validation, layout, and rendering
cvanelteren 6f99b7d
Compact treemap gallery example using shared rc settings
cvanelteren 798e2be
Merge branch 'main' into feat/treemap
cvanelteren 06ce5bd
Reuse shared color handling for treemaps
cvanelteren 6220575
Merge branch 'main' into feat/treemap
cvanelteren 60d0f91
Align treemap labels with literal label semantics
cvanelteren 7d54509
Merge branch 'main' into feat/treemap
cvanelteren f24a3fe
Stabilize treemap strip sizing and validate color options
cvanelteren 0439ddf
Handle transparent treemaps, failed draws, and overflowing group totals
cvanelteren 2e0e113
Align treemap facecolor aliases and group label contrast
cvanelteren 536827a
Validate treemap rectangle endpoints before drawing
cvanelteren 591e61f
Preserve cycle options and transparent treemap fills
cvanelteren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """ | ||
| Treemaps | ||
| ======== | ||
|
|
||
| ``PlotAxes.treemap`` represents each value by a rectangle's area. Nested | ||
| mappings group related categories inside parent rectangles. Both examples use | ||
| synthetic data. Layout and rendering require only UltraPlot's core dependencies. | ||
| """ | ||
|
|
||
| import ultraplot as uplt | ||
|
|
||
| energy = {"Solar": 36, "Wind": 28, "Hydro": 18, "Nuclear": 12, "Other": 6} | ||
| colors = ["#3c8d87", "#5286b0", "#69a4b7", "#af8a55", "#959baa"] | ||
| budget = { | ||
| "Research": {"Fieldwork": 24, "Equipment": 16, "Data": 10}, | ||
| "People": {"Staff": 20, "Training": 10}, | ||
| "Operations": {"Travel": 12, "Services": 8}, | ||
| } | ||
|
|
||
| fig, axs = uplt.subplots(ncols=2, refwidth=4.2, refaspect=1, share=False) | ||
| with uplt.rc.context({"treemap.show_values": True, "treemap.pad": 0.012}): | ||
| axs[0].treemap(energy, color=colors, value_format="{:.0f}%", text_kw={"size": 11}) | ||
| axs[1].treemap(budget, text_kw={"size": 10}) | ||
|
|
||
| axs[0].format(title="Flat categories") | ||
| axs[1].format(title="Nested categories") | ||
| axs.format(suptitle="Treemaps · area shows value") | ||
| fig.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an example that labels is a str?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was intended to be the column, or entry selected from data like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I agree that it may be a bit confusing. It is currently also overloaded and used differently across plot and raincloud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to think about this, we may need to align the other in raincloud too such that it is more consistent, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with what it is now, better if there's a explanation, or examp;le. And yes, it'll be better if data, styles are handled in a consistent way.