Image plot#

[1]:
import scipp as sc
import plopp as pp

Basic image plot#

As with one-dimensional data, plotting two-dimensional data is done using the plot function.

[2]:
da = pp.data.data2d()
da.plot()
[2]:
../../_images/user-guide_plot-types_image-plot_3_0.svg

Changing the colormap#

[3]:
da.plot(cmap='magma')
[3]:
../../_images/user-guide_plot-types_image-plot_5_0.svg

Hiding the colorbar#

[4]:
da.plot(cbar=False)
[4]:
../../_images/user-guide_plot-types_image-plot_7_0.svg

Logarithmic colormap#

[5]:
da.plot(norm='log')
[5]:
../../_images/user-guide_plot-types_image-plot_9_0.svg

Logarithmic axes#

[6]:
da.plot(scale={'x': 'log'})
[6]:
../../_images/user-guide_plot-types_image-plot_11_0.svg

Setting the axes limits#

Setting the axes limits is done by simply slicing the data before plotting it:

[7]:
pp.plot(da['x', :40]['y', 10:30])
[7]:
../../_images/user-guide_plot-types_image-plot_13_0.svg

Setting the colorscale limits#

[8]:
da.plot(vmin=sc.scalar(0, unit='m/s'), vmax=sc.scalar(0.5, unit='m/s'))
[8]:
../../_images/user-guide_plot-types_image-plot_15_0.svg

Note that if the unit in the supplied limits is not identical to the data units, an on-the-fly conversion is attempted. It is also possible to omit the units altogether, in which case it is assumed the unit is the same as the data unit.

[9]:
da.plot(vmin=0, vmax=0.5)
[9]:
../../_images/user-guide_plot-types_image-plot_17_0.svg

Masks on images#

[10]:
da.masks['yband'] = abs(da.coords['y'] - sc.scalar(20, unit='m')) < sc.scalar(5, unit='m')
da.plot()
[10]:
../../_images/user-guide_plot-types_image-plot_19_0.svg

Using a non-dimension coordinate#

For a dimension of name 'x', Plopp will use the corresponding coordinate of name 'x'. To use a different coordinate, use the coords argument.

[11]:
da = pp.data.data2d()
da.coords['x2'] = da.coords['x'] ** 2
da.coords['y2'] = da.coords['y'] ** 2
pp.plot(da, coords=['x2', 'y2'])
[11]:
../../_images/user-guide_plot-types_image-plot_21_0.svg

Note that if no coordinate of name 'x' exists, a dummy one will be generated using scipp.arange.