{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyOUyVZGsP236p26ZXnH/rXn"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["# Sunburst Charts\n","\n","Multilevel pie charts are known as sunburst charts. We can create a sunburst chart using the `plotly.express` `px.sunburst()` function. Let's say we have a family tree that we want to represent using a sunburst chart. With `px.sunburst()`, each row of the `DataFrame` is a sector of the sunburst. Each sector in the sunburst chart is analogous to a slice of the pie in a pie chart."],"metadata":{"id":"BLXMslJkfFfB"}},{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":542},"id":"01oiKxjbfDMp","executionInfo":{"status":"ok","timestamp":1706150403572,"user_tz":300,"elapsed":3958,"user":{"displayName":"Katherine Walden","userId":"17094108395123900917"}},"outputId":"f87dca12-ca95-4548-c9a7-9343f033b133"},"outputs":[{"output_type":"display_data","data":{"text/html":["\n","\n","\n","
\n","
\n","\n",""]},"metadata":{}}],"source":["import plotly.express as px # import statement\n","\n","# dictionary with data\n","data = dict(\n"," character=[\"Eve\", \"Cain\", \"Seth\", \"Enos\", \"Noam\", \"Abel\", \"Awan\", \"Enoch\", \"Azura\"],\n"," parent=[\"\", \"Eve\", \"Eve\", \"Seth\", \"Seth\", \"Eve\", \"Eve\", \"Awan\", \"Eve\" ],\n"," value=[10, 14, 12, 10, 2, 6, 6, 4, 4])\n","\n","# create figure\n","fig =px.sunburst(\n"," data,\n"," names='character',\n"," parents='parent',\n"," values='value',\n",")\n","\n","# show figure\n","fig.show()"]},{"cell_type":"markdown","source":["## Additional Resources\n","\n","- [`plotly`, Sunburst Charts in Python](https://plotly.com/python/sunburst-charts/)\n","- [`plotly.express.sunburst`](https://plotly.com/python-api-reference/generated/plotly.express.sunburst)\n","- [`plotly`, Python Figure Reference: `sunburst` Traces](https://plotly.com/python/reference/sunburst/)"],"metadata":{"id":"xZG1LIB0fRLG"}}]}