.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/plotly/plot_main06_treemap_v1.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_plotly_plot_main06_treemap_v1.py: 06. Plot Treemap with coffee ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 7-8 Lets load the dataset. .. GENERATED FROM PYTHON SOURCE LINES 8-34 .. code-block:: default :lineno-start: 9 # Libraries import plotly.graph_objects as go import pandas as pd from plotly.io import show try: __file__ TERMINAL = True except: TERMINAL = False # Define URL URL = 'https://raw.githubusercontent.com/plotly/datasets/96c0bd/sunburst-coffee-flavors-complete.csv' # Load dataframe df = pd.read_csv(URL) # Show if TERMINAL: print("\nDF:") print(df) df .. raw:: html
ids labels parents
0 Coffee Coffee Flavors NaN
1 Aromas Aromas Coffee
2 Tastes Tastes Coffee
3 Aromas-Enzymatic Enzymatic Aromas
4 Aromas-Sugar Browning Sugar Browning Aromas
... ... ... ...
92 Pungent-Thyme Thyme Spicy-Pungent
93 Smokey-Tarry Tarry Carbony-Smokey
94 Smokey-Pipe Tobacco Pipe Tobacco Carbony-Smokey
95 Ashy-Burnt Burnt Carbony-Ashy
96 Ashy-Charred Charred Carbony-Ashy

97 rows × 3 columns



.. GENERATED FROM PYTHON SOURCE LINES 36-54 .. code-block:: default :lineno-start: 37 # Display fig = go.Figure(go.Treemap( ids=df.ids, labels=df.labels, parents=df.parents, pathbar_textfont_size=15, #maxdepth=3, root_color="lightgrey" )) # Update fig.update_layout( uniformtext=dict(minsize=10, mode='hide'), margin=dict(t=50, l=25, r=25, b=25) ) # Show show(fig) .. raw:: html :file: images/sphx_glr_plot_main06_treemap_v1_001.html .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.450 seconds) .. _sphx_glr_download__examples_plotly_plot_main06_treemap_v1.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_main06_treemap_v1.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_main06_treemap_v1.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_