{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotting N-D data\n", "\n", "Data with any number of dimensions can also be plotted in Scipp." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import scipp as sc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Default representation\n", "\n", "Data with 3 or more dimensions are by default represented by a 2-D image, accompanied by sliders to navigate the extra dimensions (one slider per dimension above 2)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "N = 50\n", "M = 40\n", "L = 30\n", "K = 20\n", "xx = np.arange(N, dtype=np.float64)\n", "yy = np.arange(M, dtype=np.float64)\n", "zz = np.arange(L, dtype=np.float64)\n", "qq = np.arange(K, dtype=np.float64)\n", "x, y, z, q = np.meshgrid(xx, yy, zz, qq, indexing='ij')\n", "b = N/20.0\n", "c = M/2.0\n", "d = L/2.0\n", "r = np.sqrt(((x-c)/b)**2 + ((y-c)/b)**2 + ((z-d)/b)**2 + ((q-d)/b)**2)\n", "a = np.sin(r)\n", "d = sc.Dataset()\n", "d['Some4Ddata'] = sc.Variable(dims=['x', 'y', 'z', 'Q_x'], values=a)\n", "d.coords['x'] = sc.Variable(dims=['x'], values=xx)\n", "d.coords['y'] = sc.Variable(dims=['y'], values=yy)\n", "d.coords['z'] = sc.Variable(dims=['z'], values=zz)\n", "d.coords['Q_x'] = sc.Variable(dims=['Q_x'], values=qq)\n", "sc.plot(d)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Slider controls\n", "\n", "- Each dimension comes with two sliders to control the position of the slice and its thickness.\n", "\n", "- Upon figure creation, the thickness is set to the first bin width.\n", "Only the data contained in that bin is displayed.\n", "The thickness can be increased by an integer number of bins, and the data inside those bins will either be summed or averaged (see note below).\n", "\n", "- Changing the slice thickness will also change the color range, and the `Rescale` button can be used to automatically rescale the colorbar to the limits of the currently displayed data.\n", "\n", "- Each dimension control comes with a `Continuous Update` checkbox, which is applied by default.\n", "If this is unselected, the plot will only update once the slider has been released.\n", "\n", "