.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_axes_grid1_simple_rgb.py: ========== Simple RGB ========== .. image:: /gallery/axes_grid1/images/sphx_glr_simple_rgb_001.png :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes def get_demo_image(): import numpy as np from matplotlib.cbook import get_sample_data f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False) z = np.load(f) # z is a numpy array of 15x15 return z, (-3, 4, -4, 3) def get_rgb(): Z, extent = get_demo_image() Z[Z < 0] = 0. Z = Z / Z.max() R = Z[:13, :13] G = Z[2:, 2:] B = Z[:13, 2:] return R, G, B fig = plt.figure() ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) r, g, b = get_rgb() kwargs = dict(origin="lower", interpolation="nearest") ax.imshow_rgb(r, g, b, **kwargs) ax.RGB.set_xlim(0., 9.5) ax.RGB.set_ylim(0.9, 10.6) plt.show() .. _sphx_glr_download_gallery_axes_grid1_simple_rgb.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: simple_rgb.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: simple_rgb.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_