.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_numpy_auto_examples_plot_distances.py: Distances exercise ================== Plot distances in a grid .. image:: /intro/numpy/auto_examples/images/sphx_glr_plot_distances_001.png :class: sphx-glr-single-img .. code-block:: python import numpy as np import matplotlib.pyplot as plt x, y = np.arange(5), np.arange(5)[:, np.newaxis] distance = np.sqrt(x ** 2 + y ** 2) plt.pcolor(distance) plt.colorbar() plt.show() **Total running time of the script:** ( 0 minutes 0.084 seconds) .. _sphx_glr_download_intro_numpy_auto_examples_plot_distances.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_distances.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_distances.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_