{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Curve\n\nOne-dimensional curves as a function of the same axis.\n\nThe x-axis defines a regular 1D grid. As illustrated in this example,\nthe grid is not necessarily equally spaced.\n\n.. code::\n\n @NX_class = \"NXroot\"\n @default = \"scan1\"\n scan1:NXentry\n @NX_class = \"NXentry\"\n @default = \"data\"\n data:NXdata\n @NX_class = \"NXdata\"\n @auxiliary_signals = [\"y2\"]\n @axes = [\"x\"]\n @signal = \"y1\"\n x:NX_INT64[10]\n y1:NX_FLOAT64[10]\n y2:NX_FLOAT64[10]\n\nExplanation:\n\n1. ``@axes`` has one value which corresponds to the signal rank of one.\n\n2. ``y1`` is the default signal to be plotted versus ``x``.\n\n3. ``y2`` is the only alternative signal to be plotted versus ``x``.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Data\nimport numpy as np\n\nx = [0, 1, 8, 30, 35, 150, 200, 340, 500, 520]\ny1 = 4 + np.sin(2 * np.array(x))\ny2 = 2 + np.sin(3 * np.array(x))\n\n# Plot\nimport matplotlib.pyplot as plt # noqa E402\n\nplt.style.use(\"_mpl-gallery\")\n\nfig, ax = plt.subplots()\n\nax.plot(x, y1, \"o-\", label=\"y1\")\nax.plot(x, y2, \"go-\", label=\"y2\")\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 }