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/plotting_image-plot_3_0.svg

Changing the colormap#

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

Hiding the colorbar#

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

Logarithmic colormap#

[5]:
da.plot(logc=True)
[5]:
../_images/plotting_image-plot_9_0.svg

Logarithmic axes#

[6]:
da.plot(logx=True)
[6]:
../_images/plotting_image-plot_11_0.svg

Setting the axes limits#

[7]:
pp.plot(da, xmax=sc.scalar(25, unit='m'))
[7]:
../_images/plotting_image-plot_13_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.

[8]:
pp.plot(da, xmax=25, ymin=10, ymax=30)
[8]:
../_images/plotting_image-plot_15_0.svg

Setting the colorscale limits#

Similarly to the axes limits, the colorscale limits are controlled via the cmin/cmax arguments:

[9]:
da.plot(cmin=sc.scalar(0, unit='m/s'), cmax=0.5)
[9]:
../_images/plotting_image-plot_17_0.svg

Masks on images#

The masked data are by default represented using a grayscale colormap:

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

The colormap for the masks can be changed using the mask_cmap argument:

[11]:
da.plot(mask_cmap='hot')
[11]:
../_images/plotting_image-plot_21_0.svg

Masks can also be a solid color:

[12]:
da.plot(mask_color='magenta')
[12]:
../_images/plotting_image-plot_23_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.

[13]:
da = pp.data.data2d()
da.coords['x2'] = da.coords['x'] ** 2
da.coords['y2'] = da.coords['y'] ** 2
pp.plot(da, coords=['x2', 'y2'])
[13]:
../_images/plotting_image-plot_25_0.svg

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