.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_ranges.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_gallery_plot_ranges.py: ========================= Ranges of timeseries data ========================= .. GENERATED FROM PYTHON SOURCE LINES 7-10 .. code-block:: Python # sphinx_gallery_thumbnail_number = 3 .. GENERATED FROM PYTHON SOURCE LINES 11-21 Read in tutorial data and show a summary **************************************** This gallery uses the scenario data from the first-steps tutorial. If you haven't cloned the **pyam** GitHub repository to your machine, you can download the file from https://github.com/IAMconsortium/pyam/tree/main/docs/tutorials. Make sure to place the data file in the same folder as this script/notebook. .. GENERATED FROM PYTHON SOURCE LINES 21-29 .. code-block:: Python import matplotlib.pyplot as plt import pyam df = pyam.IamDataFrame("tutorial_data.csv") df .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/pyam-iamc/checkouts/stable/pyam/utils.py:318: FutureWarning: The previous implementation of stack is deprecated and will be removed in a future version of pandas. See the What's New notes for pandas 2.1.0 for details. Specify future_stack=True to adopt the new implementation and silence this warning. Index: * model : AIM/CGE 2.1, GENeSYS-MOD 1.0, ... WITCH-GLOBIOM 4.4 (8) * scenario : 1.0, CD-LINKS_INDCi, CD-LINKS_NPi, ... Faster Transition Scenario (8) Timeseries data coordinates: region : R5ASIA, R5LAM, R5MAF, R5OECD90+EU, R5REF, R5ROWO, World (7) variable : ... (6) unit : EJ/yr, Mt CO2/yr, °C (3) year : 2010, 2020, 2030, 2040, 2050, 2060, 2070, 2080, ... 2100 (10) .. GENERATED FROM PYTHON SOURCE LINES 30-35 Highlighting ranges in a line chart *********************************** In this example, we want to highlight the range across a scenario ensemble. We do this by utilizing the `fill_between` argument. .. GENERATED FROM PYTHON SOURCE LINES 35-42 .. code-block:: Python data = df.filter(scenario="CD-LINKS*", variable="Emissions|CO2", region="World") data.plot(color="scenario", fill_between=True) plt.tight_layout() plt.show() .. image-sg:: /gallery/images/sphx_glr_plot_ranges_001.png :alt: region: World - variable: Emissions|CO2 :srcset: /gallery/images/sphx_glr_plot_ranges_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-49 More options for highlighting ranges in a line chart **************************************************** The keyword argument `fill_between` can be set to true, or it can be provided specific arguments as a dictionary: in this illustration, we choose a very low transparency value. .. GENERATED FROM PYTHON SOURCE LINES 49-54 .. code-block:: Python data.plot(color="scenario", fill_between=dict(alpha=0.15)) plt.tight_layout() plt.show() .. image-sg:: /gallery/images/sphx_glr_plot_ranges_002.png :alt: region: World - variable: Emissions|CO2 :srcset: /gallery/images/sphx_glr_plot_ranges_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 55-61 Even more options for highlighting ranges in a line chart ********************************************************* To further highlight the range of data, we can also add a bar showing the range of data in the final time period using `final_ranges`. Similar to `fill_between` it can either be true or have specific arguments. .. GENERATED FROM PYTHON SOURCE LINES 61-65 .. code-block:: Python data.plot(color="scenario", fill_between=True, final_ranges=dict(linewidth=5)) plt.tight_layout() plt.show() .. image-sg:: /gallery/images/sphx_glr_plot_ranges_003.png :alt: region: World - variable: Emissions|CO2 :srcset: /gallery/images/sphx_glr_plot_ranges_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.614 seconds) .. _sphx_glr_download_gallery_plot_ranges.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ranges.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ranges.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_