sunburst

Draw sunburst charts/hierarchical pie plots ("multi-level" pie plots of hierarchical data as e.g., in disk usage diagrams)

https://github.com/klieret/sunburst

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

chart hierarchical-data pie-chart plot plotting pyplot python visualization

Keywords from Contributors

distributed particles mesh interpretability energy-system-model parallel autograd tensor names name-generation
Last synced: 6 months ago · JSON representation

Repository

Draw sunburst charts/hierarchical pie plots ("multi-level" pie plots of hierarchical data as e.g., in disk usage diagrams)

Basic Info
  • Host: GitHub
  • Owner: klieret
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: master
  • Homepage: https://sunburst.rtfd.io
  • Size: 210 KB
Statistics
  • Stars: 14
  • Watchers: 1
  • Forks: 2
  • Open Issues: 6
  • Releases: 1
Topics
chart hierarchical-data pie-chart plot plotting pyplot python visualization
Created over 9 years ago · Last pushed 8 months ago
Metadata Files
Readme Changelog License

README.md

Sunburst Charts

gh actions pre-commit.ci status Documentation Status Pypi status PR welcome Black License

🔖 Check out the full documentation!

🚧 This is an older project that is currently being brushed up 🚧

Introduction

sunburst creates "sunburst charts" (also called "Ring Charts", "Hierarchical Pie Chargs" or "Multilevel Pie Charts") together with the matplotlib package. Quoting Wikipedia:

A ring chart, also known as a sunburst chart or a multilevel pie chart, is used to visualize hierarchical data, depicted by concentric circles. The circle in the centre represents the root node, with the hierarchy moving outward from the center. A segment of the inner circle bears a hierarchical relationship to those segments of the outer circle which lie within the angular sweep of the parent segment.

A prominent example are disk usage charts (see examples/disk_usage_plot.py for this example):

✨ Features

sunburst tries to be

  • Intuitive & Easy to use: After setting up your data and matplotlib, not more than two lines are necessary to generate first plots (minimal example).
  • Flexible & Robust: Wherever it makes sense, the methods of the SunburstPlot class are intended to be overwritten. Methods that are responsible for spacing, coloring, styling etc. of the wedges take the corresponding data point (path) as an argument, allowing to set most properties independently for each wedge.

More specifically:

  • Clever positioning of labels, which - depending on space constraints are positioned in a tangentially or radially.
  • An easy way to "explode" the plot by redefining sunburst.wedge_spacing (example, example).

📦 Installation

To install, run

bash pip3 install sunburst

🚧 Migration notice

For more information about recent changes, see the changelog.

  • The 2.0 version will have a different API without the Path class
  • Before the first release to pypi, this package was called hpie.
    • There have since bean many non-backwards compatible changes to the API: Most importantly, the HPie class is now SunburstPlot and the package is called sunburst
    • To get the old version back, check out the old-hpie branch. It will however not be maintained any longer.

🔥 Minimal example

You can find several examples at examples/. The most basic example is minimal_example_sunburst.py:

```python import matplotlib.pyplot as plt from sunburst import SunburstPlot, stringvaluestopv

set up some data

data = stringvaluestopv({ 'ipsum': 40.45, 'ipsum/eirmod': 29.34, 'ipsum/eirmod/dolor': 94.4, 'lorem': 36.12, 'lorem/sadipscing/dolor': 44.32, 'lorem/sadipscing/lorem': 37.15, 'lorem/sadipscing/nonumy': 23.98, 'lorem/eirmod': 11.12, 'lorem/eirmod/lorem': 45.65, 'lorem/sadipscing': 79.67, })

fig, ax = plt.subplots() sbp = SunburstPlot(data, ax) sbp.plot(setupaxes=True) ax.settitle('Example SunburstPlot')

plt.show() ```

Running this script with python3 minimal_example_sunburst.py will produce the following plot:

The Data

Note that the value corresponding to path is always the value excluding the values of the children of the path. Therefore plotting the SunburstPlot object computes a "completed" version of the "pathvalue dictionary". You can check this with the SunburstPlot._completed_pv instance variable which gets initialized after calling SunburstPlot.plot(*args). Running our minimal example prints the following:

python sbp._completed_pv.items() = { Path((, )): 442.2, # = the total sum of all items = # = 36.12 + 44.32 + 37.15 + 23.98 + ... Path(('ipsum', )): 164.19000000000003, # = sum of "ipsum" and all of its children = # = 40.45 + 29.34 + 94.4 Path(('ipsum', 'eirmod', )): 123.74000000000001, # = sum of ipsum/eirmod and all of its children = # = 29.34 + 94.4 Path(('ipsum', 'eirmod', 'dolor', )): 94.4, Path(('lorem', )): 278.01, Path(('lorem', 'eirmod', )): 56.769999999999996, Path(('lorem', 'eirmod', 'lorem', )): 45.65, Path(('lorem', 'sadipscing', )): 185.12, Path(('lorem', 'sadipscing', 'dolor', )): 44.32, Path(('lorem', 'sadipscing', 'lorem', )): 37.15, Path(('lorem', 'sadipscing', 'nonumy', )): 23.98, }

sunburst/tests/test_calc.py contains an explicit test of this calculation based on a similar example.

Ring Charts

Thus you get ring charts, if and only if all of the non-zero values correspond to paths with the same length. E.g. if we change the above data as follows (by lengthening the paths with question marks and removing the entry for the empty path):

python data = stringvalues_to_pv({ 'ipsum/?/?': 40.45, 'ipsum/eirmod/?': 29.34, 'ipsum/eirmod/dolor': 94.4, 'lorem/?/?': 36.12, 'lorem/sadipscing/dolor': 44.32, 'lorem/sadipscing/lorem': 37.15, 'lorem/sadipscing/nonumy': 23.98, 'lorem/eirmod/?': 11.12, 'lorem/eirmod/lorem': 45.65, 'lorem/sadipscing/?': 79.67, })

we should get a classical ring chart. This is minimal_example_rings.py. Running it via python3 minimal_example_rings.py yields the following plot, which indeed just fills up the white space of the above plot with wedges labeled ?.

License

This project is licensed under the BSD 3-Clause License, see LICENSE.txt.

Owner

  • Name: Kilian Lieret
  • Login: klieret
  • Kind: user
  • Location: Princeton, NJ, USA
  • Company: Princeton University

Postdoctoral Research Associate at Princeton University Research Computing

GitHub Events

Total
  • Watch event: 1
  • Push event: 4
Last Year
  • Watch event: 1
  • Push event: 4

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 199
  • Total Committers: 5
  • Avg Commits per committer: 39.8
  • Development Distribution Score (DDS): 0.407
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
klieret k****t 118
Kilian Lieret k****t@p****e 68
dependabot[bot] 4****] 6
pre-commit-ci[bot] 6****] 6
Christian Glusa c****a@s****v 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 7
  • Total pull requests: 19
  • Average time to close issues: 3 days
  • Average time to close pull requests: 15 days
  • Total issue authors: 1
  • Total pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.95
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 15
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • klieret (7)
Pull Request Authors
  • dependabot[bot] (8)
  • pre-commit-ci[bot] (7)
  • klieret (3)
  • cgcgcg (1)
Top Labels
Issue Labels
enhancement (4) bug (1)
Pull Request Labels
dependencies (8)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 46 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 1
  • Total maintainers: 1
pypi.org: sunburst

Use matplotlib to plot sunburst charts/hierarchical pie charts/ring charts/multilevel pie charts (as e.g. in disk usage diagrams).

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 46 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 15.6%
Forks count: 19.1%
Average: 19.2%
Dependent repos count: 21.5%
Downloads: 29.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

doc/requirements.txt pypi
  • sphinx_book_theme *
  • sunburst master
.github/workflows/release.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish master composite
.github/workflows/test-release.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish master composite
.github/workflows/test.yaml actions
  • AndreMiras/coveralls-python-action develop composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
pyproject.toml pypi
setup.py pypi