.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "sources/visualisation/sunburst.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_sources_visualisation_sunburst.py: Sunburst Plots ============== .. GENERATED FROM PYTHON SOURCE LINES 7-67 Sunburst plots, also known as `ring charts `_, can be generated using the :py:func:`~isaricanalytics.visualisation.fig_sunburst` function, which returns a :py:class:`Plotly Go Figure ` object. The plot below was generated using a synthetic dataset of patient enrolment data organised by site and country. The synthetic dataset is given as a table (which can easily be converted to a CSV). .. list-table:: Synthetic dataset for patient enrolment at clinical sites filtered by country :header-rows: 1 :widths: auto * - Site - Country - Subject Id * - 0 - COL - 21 * - 2 - COL - 25 * - 3 - GBR - 199 * - 5 - CAN - 31 * - 6 - BRA - 156 * - 7 - BRA - 27 * - 8 - BRA - 8 * - 9 - FRA - 174 * - 10 - POL - 89 * - 11 - POL - 30 * - 13 - RWA - 121 * - 14 - KEN - 1 * - 15 - KEN - 15 * - 16 - KEN - 1 * - 18 - NLD - 102 The data source can be in any appropriate form, such as, typically, a CSV. Here are the Python steps you need to generate the plot using the :py:func:`~isaricanalytics.visualisation.fig_sunburst` function: .. GENERATED FROM PYTHON SOURCE LINES 67-105 .. code-block:: Python import io import pandas as pd from isaricanalytics.visualisation import fig_sunburst # Load the CSV data from a string buffer data = pd.read_csv( io.StringIO( """Site,Country,SubjectID\n 0,COL,21\n2,COL,25\n 3,GBR,199\n 5,CAN,31\n 6,BRA,156\n 7,BRA,27\n 8,BRA,8\n 9,FRA,174\n 10,POL,89\n 11,POL,30\n 13,RWA,121\n 14,KEN,1\n 15,KEN,15\n 16,KEN,1\n 18,NLD,102\n""", ), skipinitialspace=True, ) # Create and display the figure fig = fig_sunburst( data, title="Sunburst Plot of Synthetic Patient Enrolment Data Organised by Site and Country", path=["Country", "Site"], values="SubjectID", ) fig.update_layout(autosize=True) fig .. raw:: html .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 106-119 You should see the plot appearing as given above. .. note:: Any dataframe or CSV column names, or dictionary field labels, in the example above that are not specific to the dataset must be as given, otherwise the function may throw an exception or return an incorrect figure. The figure height and width parameters can be set using the ``height`` and ``width`` parameters, but it may be more convenient to let Plotly handle this using the figure layout `autosize `_ parameter. Refer to the :py:func:`~isaricanalytics.visualisation.fig_sunburst` function docstring for more information. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.235 seconds) .. _sphx_glr_download_sources_visualisation_sunburst.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: sunburst.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: sunburst.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: sunburst.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_