.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "source/auto_examples/plotting/plot_pie_chart.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_source_auto_examples_plotting_plot_pie_chart.py: Calculate and View Aerosol Percentages -------------------------------------- Calculate the percentages of different aerosols in a Aerosol Chemical Speciation (AOS) monitor dataset and view the percentages in a pie chart. Written: Zach Sherman .. GENERATED FROM PYTHON SOURCE LINES 12-53 .. image-sg:: /source/auto_examples/plotting/images/sphx_glr_plot_pie_chart_001.png :alt: sgpaosacsmE13.b2 on 20230420 :srcset: /source/auto_examples/plotting/images/sphx_glr_plot_pie_chart_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none KeysView(Data variables: base_time datetime64[ns] 8B 2023-04-20 time_offset (time) datetime64[ns] 408B 2023-04-20T00:01... time_bounds (time, bound) object 816B dask.array total_organics (time) float32 204B dask.array qc_total_organics (time) int32 204B dask.array sulfate (time) float32 204B dask.array qc_sulfate (time) int32 204B dask.array ammonium (time) float32 204B dask.array qc_ammonium (time) int32 204B dask.array nitrate (time) float32 204B dask.array qc_nitrate (time) int32 204B dask.array chloride (time) float32 204B dask.array qc_chloride (time) int32 204B dask.array airbeam_normalization_factor (time) float32 204B dask.array inlet_pressure (time) float32 204B dask.array lat float32 4B ... lon float32 4B ... alt float32 4B ...) /home/runner/work/ACT/ACT/act/utils/data_utils.py:1398: UserWarning: No time parameter used, calculating a mean for each field for the whole dataset. warnings.warn( | .. code-block:: Python from arm_test_data import DATASETS import matplotlib.pyplot as plt import act from act.io.arm import read_arm_netcdf # Read an ARM AOS dataset filename = DATASETS.fetch('sgpaosacsmE13.b2.20230420.000109.nc') ds = read_arm_netcdf(filename) # Let us print out the fields in the dataset and see what it contains. print(ds.data_vars.keys()) # Knowing what fields the dataset contains, let's create a list of fields # to use in the plot. fields = ['sulfate', 'ammonium', 'nitrate', 'chloride'] # We also want to provide some keyword arguments to avoid invalid data such # as negative values. threshold = 0.0 fill_value = 0.0 # Create a DistributionDisplay object to compare fields display = act.plotting.DistributionDisplay(ds) # We can set one of the slices to explode and give it a nice shadow. explode = (0, 0.1, 0, 0) shadow = True # Create a pie chart using the fields list. The percentages of the # fields will be calculated using act.utils.calculate_percentages. display.plot_pie_chart( fields, threshold=threshold, fill_value=fill_value, explode=explode, shadow=True, ) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.080 seconds) .. _sphx_glr_download_source_auto_examples_plotting_plot_pie_chart.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_pie_chart.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_pie_chart.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_pie_chart.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_