.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_scatter.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_scatter.py: ============ Scatter plot ============ .. GENERATED FROM PYTHON SOURCE LINES 9-19 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/master/docs/tutorials. Make sure to place the data file in the same folder as this script/notebook. .. GENERATED FROM PYTHON SOURCE LINES 19-27 .. 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/latest/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 28-33 Show relation of variables ************************** In the first example, we show the relation between two variables, biomass and fossil energy use. .. GENERATED FROM PYTHON SOURCE LINES 33-42 .. code-block:: Python data = df.filter(region="World") data.plot.scatter( x="Primary Energy|Biomass", y="Primary Energy|Fossil", color="scenario" ) plt.tight_layout() plt.show() .. image-sg:: /gallery/images/sphx_glr_plot_scatter_001.png :alt: plot scatter :srcset: /gallery/images/sphx_glr_plot_scatter_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-54 Show a scatter plot of meta indicators ************************************** In the second example, we show the relation between two meta indicators computed from the timeseries data. Cumulative CO2 emissions ======================== The first indicator computes the cumulative CO2 emissions from 2020 until the end of the century. .. GENERATED FROM PYTHON SOURCE LINES 54-66 .. code-block:: Python co2 = ( df.filter(region="World", variable="Emissions|CO2") .convert_unit("Mt CO2/yr", "Gt CO2/yr") .timeseries() ) df.set_meta( meta=co2.apply(pyam.timeseries.cumulative, first_year=2020, last_year=2100, axis=1), name="cumulative_co2", ) .. GENERATED FROM PYTHON SOURCE LINES 67-72 Temperature at the end of the century ===================================== The second indicator takes the value of the temperature variable in the latest year and assigns it as a meta indicator. .. GENERATED FROM PYTHON SOURCE LINES 72-76 .. code-block:: Python temperature_var = "AR5 climate diagnostics|Temperature|Global Mean|MAGICC6|MED" df.set_meta_from_data(name="temperature", variable=temperature_var, year=2100) .. GENERATED FROM PYTHON SOURCE LINES 77-80 Draw the scatter plot! ====================== .. GENERATED FROM PYTHON SOURCE LINES 80-82 .. code-block:: Python df.plot.scatter(x="cumulative_co2", y="temperature", color="scenario") .. image-sg:: /gallery/images/sphx_glr_plot_scatter_002.png :alt: plot scatter :srcset: /gallery/images/sphx_glr_plot_scatter_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.035 seconds) .. _sphx_glr_download_gallery_plot_scatter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_scatter.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_scatter.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_