{"id":15677586,"url":"https://github.com/klieret/sunburst","last_synced_at":"2025-08-15T20:33:02.763Z","repository":{"id":40547665,"uuid":"72367781","full_name":"klieret/sunburst","owner":"klieret","description":"Draw sunburst charts/hierarchical pie plots (\"multi-level\" pie plots of hierarchical data as e.g., in disk usage diagrams)","archived":false,"fork":false,"pushed_at":"2025-07-07T21:56:11.000Z","size":215,"stargazers_count":13,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T01:21:44.257Z","etag":null,"topics":["chart","hierarchical-data","pie-chart","plot","plotting","pyplot","python","visualization"],"latest_commit_sha":null,"homepage":"https://sunburst.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klieret.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-10-30T18:37:36.000Z","updated_at":"2024-05-08T10:22:45.000Z","dependencies_parsed_at":"2023-12-12T18:20:57.120Z","dependency_job_id":"f25eac2a-6118-4fc8-9532-a336112c68b7","html_url":"https://github.com/klieret/sunburst","commit_stats":{"total_commits":197,"total_committers":5,"mean_commits":39.4,"dds":0.4010152284263959,"last_synced_commit":"2cf0d0002abeb94c5c6ecf8aeaaead68a3e91a45"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/klieret/sunburst","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fsunburst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fsunburst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fsunburst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fsunburst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klieret","download_url":"https://codeload.github.com/klieret/sunburst/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fsunburst/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270625158,"owners_count":24618333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","hierarchical-data","pie-chart","plot","plotting","pyplot","python","visualization"],"created_at":"2024-10-03T16:09:56.473Z","updated_at":"2025-08-15T20:33:02.736Z","avatar_url":"https://github.com/klieret.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sunburst Charts\n\n[![gh actions](https://github.com/klieret/sunburst/actions/workflows/test.yaml/badge.svg)](https://github.com/klieret/sunburst/actions)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/klieret/sunburst/master.svg)](https://results.pre-commit.ci/latest/github/klieret/sunburst/master)\n[![Documentation Status](https://readthedocs.org/projects/sunburst/badge/?version=latest)](http://sunburst.readthedocs.io/en/latest/)\n[![Pypi status](https://badge.fury.io/py/sunburst.svg)](https://pypi.org/project/sunburst/)\n[![PR welcome](https://img.shields.io/badge/PR-Welcome-%23FF8300.svg)](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project)\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)\n[![License](https://img.shields.io/github/license/klieret/sunburst.svg)](https://github.com/klieret/sunburst/blob/master/LICENSE.txt)\n\n🔖 **Check out the [full documentation](https://sunburst.readthedocs.io/en/latest/)!**\n\n🚧 **This is an older project that is currently being brushed up** 🚧\n\n## Introduction\n\n`sunburst` creates \"sunburst charts\" (also called \"Ring Charts\", \"Hierarchical Pie Chargs\" or \"Multilevel Pie Charts\") together with the `matplotlib` package.\nQuoting [Wikipedia](https://en.wikipedia.org/wiki/Pie_chart#Ring_chart_.2F_Sunburst_chart_.2F_Multilevel_pie_chart):\n\n\u003e A ring chart, also known as a sunburst chart or a multilevel pie\n\u003e chart, is used to visualize hierarchical data, depicted by concentric circles. The circle in the centre represents the root node, with the\n\u003e hierarchy moving outward from the center. A segment of the inner\n\u003e circle bears a hierarchical relationship to those segments of the\n\u003e outer circle which lie within the angular sweep of the parent segment.\n\nA prominent example are disk usage charts (see\n`examples/disk_usage_plot.py` for this example):\n\n![](https://cloud.githubusercontent.com/assets/13602468/20408444/c8cb6a56-ad15-11e6-8f5c-1abef69dc551.png)\n\n## ✨ Features\n\n`sunburst` tries to be\n\n-   Intuitive \u0026 Easy to use: After setting up your data and\n    `matplotlib`, not more than two lines are necessary to generate\n    first plots ([minimal\n    example](https://github.com/klieret/sunburst/blob/master/examples/minimal_example_sunburst.py)).\n-   Flexible \u0026 Robust: Wherever it makes sense, the methods of the\n    `SunburstPlot` class are intended to be overwritten. Methods that\n    are responsible for spacing, coloring, styling etc. of the `wedges`\n    take the corresponding data point (`path`) as an argument, allowing to set most properties independently for each `wedge`.\n\nMore specifically:\n\n-   Clever positioning of labels, which - depending on space constraints are positioned in a tangentially or radially.\n-   An easy way to \"explode\" the plot by redefining\n    `sunburst.wedge_spacing`\n    ([example](https://github.com/klieret/sunburst/blob/master/examples/minimal_example_exploded.py),\n    [example](https://github.com/klieret/sunburst/blob/master/examples/disk_usage_exploded.py)).\n\n## 📦 Installation\n\nTo install, run\n\n```bash\npip3 install sunburst\n```\n\n## 🚧 Migration notice\n\nFor more information about recent changes, see the [changelog](https://sunburst.readthedocs.io/en/latest/changelog.html).\n\n* The 2.0 version will have a different API without the `Path` class\n* Before the first release to pypi, this package was called `hpie`.\n  * 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`\n  * To get the old version back, check out the `old-hpie` branch. It will however not be maintained any longer.\n\n## 🔥 Minimal example\n\nYou can find several examples at `examples/`. The most basic example is\n`minimal_example_sunburst.py`:\n\n```python\nimport matplotlib.pyplot as plt\nfrom sunburst import SunburstPlot, stringvalues_to_pv\n\n# set up some data\ndata = stringvalues_to_pv({\n    'ipsum':                      40.45,\n    'ipsum/eirmod':               29.34,\n    'ipsum/eirmod/dolor':         94.4,\n    'lorem':                      36.12,\n    'lorem/sadipscing/dolor':     44.32,\n    'lorem/sadipscing/lorem':     37.15,\n    'lorem/sadipscing/nonumy':    23.98,\n    'lorem/eirmod':               11.12,\n    'lorem/eirmod/lorem':         45.65,\n    'lorem/sadipscing':           79.67,\n})\n\n\nfig, ax = plt.subplots()\nsbp = SunburstPlot(data, ax)\nsbp.plot(setup_axes=True)\nax.set_title('Example SunburstPlot')\n\nplt.show()\n```\n\nRunning this script with `python3 minimal_example_sunburst.py` will\nproduce the following plot:\n\n![](https://cloud.githubusercontent.com/assets/13602468/20408443/c8c8c1d4-ad15-11e6-86a6-868dc98e91d0.png)\n\n## The Data\n\nNote that the value corresponding to path is always the value\n*excluding* the values of the children of the path. Therefore plotting\nthe `SunburstPlot` object computes a \"completed\" version of the\n\"pathvalue dictionary\". You can check this with the\n`SunburstPlot._completed_pv` instance variable which gets initialized\nafter calling `SunburstPlot.plot(*args)`. Running our minimal example\nprints the following:\n\n```python\nsbp._completed_pv.items() = {\n    Path((, )): 442.2,  # = the total sum of all items =\n                        # = 36.12 + 44.32 + 37.15 + 23.98 + ...\n    Path(('ipsum', )): 164.19000000000003,  # = sum of \"ipsum\" and all of its children =\n                                            # = 40.45 + 29.34 + 94.4\n    Path(('ipsum', 'eirmod', )): 123.74000000000001, # = sum of ipsum/eirmod and all of its children =\n                                                     # = 29.34 + 94.4\n    Path(('ipsum', 'eirmod', 'dolor', )): 94.4,\n    Path(('lorem', )): 278.01,\n    Path(('lorem', 'eirmod', )): 56.769999999999996,\n    Path(('lorem', 'eirmod', 'lorem', )): 45.65,\n    Path(('lorem', 'sadipscing', )): 185.12,\n    Path(('lorem', 'sadipscing', 'dolor', )): 44.32,\n    Path(('lorem', 'sadipscing', 'lorem', )): 37.15,\n    Path(('lorem', 'sadipscing', 'nonumy', )): 23.98,\n}\n```\n\n`sunburst/tests/test_calc.py` contains an explicit test of this\ncalculation based on a similar example.\n\n## Ring Charts\n\nThus you get ring charts, if and only if all of the non-zero values\ncorrespond to paths with the same length. E.g. if we change the above data as follows (by lengthening the paths with question marks and\nremoving the entry for the empty path):\n\n```python\ndata = stringvalues_to_pv({\n    'ipsum/?/?':                 40.45,\n    'ipsum/eirmod/?':            29.34,\n    'ipsum/eirmod/dolor':        94.4,\n    'lorem/?/?':                 36.12,\n    'lorem/sadipscing/dolor':    44.32,\n    'lorem/sadipscing/lorem':    37.15,\n    'lorem/sadipscing/nonumy':   23.98,\n    'lorem/eirmod/?':            11.12,\n    'lorem/eirmod/lorem':        45.65,\n    'lorem/sadipscing/?':        79.67,\n})\n```\n\nwe should get a classical ring chart. This is\n`minimal_example_rings.py`. Running it via\n`python3 minimal_example_rings.py` yields the following plot, which\nindeed just fills up the white space of the above plot with wedges\nlabeled `?`.\n\n![](https://cloud.githubusercontent.com/assets/13602468/20408445/c8cdf4ec-ad15-11e6-9a10-2758c3469f9d.png)\n\n## License\n\nThis project is licensed under the *BSD 3-Clause License*, see\n`LICENSE.txt`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklieret%2Fsunburst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklieret%2Fsunburst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklieret%2Fsunburst/lists"}