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(norm='log')
[5]:
Logarithmic axes#
[6]:
da.plot(scale={'x': 'log'})
[6]:
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]:
Setting the colorscale limits#
[8]:
da.plot(vmin=sc.scalar(0, unit='m/s'), vmax=sc.scalar(0.5, unit='m/s'))
[8]:
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]:
Masks on images#
[10]:
da.masks['yband'] = abs(da.coords['y'] - sc.scalar(20, unit='m')) < sc.scalar(
5, unit='m'
)
da.plot()
[10]:
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]:
Note that if no coordinate of name 'x'
exists, a dummy one will be generated using scipp.arange
.