{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Image\n\nImage on a regular two-dimensional grid.\n\nThe x-axis and y-axis define a regular 2D grid. The grid is equally spaced in\nthis example but this is not necessarily the case.\n\n.. code::\n\n @NX_class = \"NXroot\"\n @default = \"scan1\"\n scan1:\n @NX_class = \"NXentry\"\n @default = \"data\"\n data:\n @NX_class = \"NXdata\"\n @axes = [\"y\", \"x\"]\n @signal = \"z\"\n x: NX_FLOAT64[16]\n y: NX_FLOAT64[30]\n z: NX_FLOAT64[30,16]\n\nExplanation:\n\n1. ``@axes`` has two values which corresponds to the signal rank of two.\n\n2. ``z`` is the default signal to be plotted versus ``x`` and ``y``.\n\n3. ``z`` has 30 rows and 16 columns.\n\n4. ``y`` spans the first dimension of ``z`` and ``x`` the second.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Data\nimport numpy as np\n\nx = np.linspace(-3, 3, 16)\ny = np.linspace(-3, 3, 30)\n\nxx, yy = np.meshgrid(x, y)\nz = (1 - xx / 2 + xx**5 + yy**3) * np.exp(-(xx**2) - yy**2)\n\n# Plot\nimport matplotlib.pyplot as plt # noqa E402\n\nplt.style.use(\"_mpl-gallery-nogrid\")\n\nfig, ax = plt.subplots()\n\nax.imshow(z, extent=[x[0], x[-1], y[0], y[-1]], origin=\"lower\")\n\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.16" } }, "nbformat": 4, "nbformat_minor": 0 }