.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_plotting_REE_v_radii.py:


REE Radii Plots
============================


.. code-block:: default

    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    from pyrolite.plot import pyroplot









Here we generate some example data, using the
:func:`~pyrolite.util.synthetic.example_spider_data` function (based on EMORB,
here normalised to Primitive Mantle);



.. code-block:: default

    from pyrolite.util.synthetic import example_spider_data

    df = example_spider_data(noise_level=0.1, nobs=20)








Where data is specified, the default plot is a line-based spiderplot:


.. code-block:: default

    ax = df.pyroplot.REE(color="0.5", figsize=(8, 4))
    plt.show()



.. image:: /examples/plotting/images/sphx_glr_REE_v_radii_001.png
    :class: sphx-glr-single-img





This behaviour can be modified (see spiderplot docs) to provide e.g. filled ranges:



.. code-block:: default

    df.pyroplot.REE(mode="fill", color="0.5", alpha=0.5, figsize=(8, 4))
    plt.show()



.. image:: /examples/plotting/images/sphx_glr_REE_v_radii_002.png
    :class: sphx-glr-single-img





The plotting axis can be specified to use exisiting axes:



.. code-block:: default

    fig, ax = plt.subplots(1, 2, sharey=True, figsize=(12, 4))

    df.pyroplot.REE(ax=ax[0])
    # we can also change the index of the second axes
    another_df = example_spider_data(noise_level=0.2, nobs=20)  # some 'nosier' data
    another_df.pyroplot.REE(ax=ax[1], color="k", index="radii")

    plt.tight_layout()
    plt.show()



.. image:: /examples/plotting/images/sphx_glr_REE_v_radii_003.png
    :class: sphx-glr-single-img





If you're just after a plotting template, you can use
:func:`~pyrolite.plot.spider.REE_v_radii` to get a formatted axis which can be used
for subsequent plotting:



.. code-block:: default

    from pyrolite.plot.spider import REE_v_radii

    ax = REE_v_radii(index="radii")  # radii mode will put ionic radii on the x axis
    plt.show()



.. image:: /examples/plotting/images/sphx_glr_REE_v_radii_004.png
    :class: sphx-glr-single-img





.. seealso::

  Examples:
   `Ionic Radii <ionic_radii.html>`__,
   `Spider Diagrams <spider.html>`__,
   `lambdas: Parameterising REE Profiles <lambdas.html>`__

  Functions:
    :func:`~pyrolite.geochem.ind.get_ionic_radii`,
    :func:`pyrolite.plot.pyroplot.REE`,
    :func:`pyrolite.plot.pyroplot.spider`,
    :func:`~pyrolite.geochem.pyrochem.lambda_lnREE`


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  3.606 seconds)


.. _sphx_glr_download_examples_plotting_REE_v_radii.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example


  .. container:: binder-badge

    .. image:: https://mybinder.org/badge_logo.svg
      :target: https://mybinder.org/v2/gh/morganjwilliams/pyrolite/develop?filepath=docs/source/examples/plotting/REE_v_radii.ipynb
      :width: 150 px


  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: REE_v_radii.py <REE_v_radii.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: REE_v_radii.ipynb <REE_v_radii.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
