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]:
Changing the colormap#
[3]:
da.plot(cmap='magma')
[3]:
Hiding the colorbar#
[4]:
da.plot(cbar=False)
[4]:
Logarithmic colormap#
[5]:
da.plot(logc=True)
[5]:
Logarithmic axes#
[6]:
da.plot(logx=True)
[6]:
Setting the axes limits#
[7]:
pp.plot(da, xmax=sc.scalar(25, unit='m'))
[7]:
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]:
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]:
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]:
The colormap for the masks can be changed using the mask_cmap
argument:
[11]:
da.plot(mask_cmap='hot')
[11]:
Masks can also be a solid color:
[12]:
da.plot(mask_color='magenta')
[12]:
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]:
Note that if no coordinate of name 'x'
exists, a dummy one will be generated using scipp.arange
.