.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_auto_examples_plot_function_identifier.py>` to download the full example code or run this example in your browser via Binder
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_function_identifier.py:


Identifying function names in a script
======================================

Calls Sphinx-Gallery identify names function to figure out which
functions are called in the script and to which module do they belong.



.. image:: /auto_examples/images/sphx_glr_plot_function_identifier_001.png
    :class: sphx-glr-single-img





.. code-block:: python


    # Code source: Óscar Nájera
    # License: BSD 3 clause

    import matplotlib.pyplot as plt
    import sphinx_gallery.backreferences as spback


    filename = spback.__file__.replace('.pyc', '.py')
    names = spback.identify_names(filename)
    figheight = len(names) + .5

    fontsize = 22
    fig = plt.figure()

    for i, (name, obj) in enumerate(names.items()):
        fig.text(0.3, (float(len(names)) - 0.5 - i) / figheight,
                 name,
                 ha="right",
                 size=fontsize,
                 transform=fig.transFigure,
                 bbox=dict(boxstyle='square', fc="w", ec="k"))
        fig.text(0.35, (float(len(names)) - 0.5 - i) / figheight,
                 obj["module"],
                 ha="left",
                 size=fontsize,
                 transform=fig.transFigure,
                 bbox=dict(boxstyle='larrow', fc="w", ec="k"))
    #
    plt.draw()
    plt.show()

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


.. _sphx_glr_download_auto_examples_plot_function_identifier.py:


.. only :: html

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


  .. container:: binder-badge

    .. image:: https://static.mybinder.org/badge.svg
      :target: https://mybinder.org/v2/gh/sphinx-gallery/sphinx-gallery.github.io/master?urlpath=lab/tree/notebooks/auto_examples/plot_function_identifier.ipynb
      :width: 150 px


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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