imshow_field¶
-
hcipy.plotting.
imshow_field
(field, grid=None, ax=None, vmin=None, vmax=None, aspect='equal', norm=None, interpolation=None, non_linear_axes=False, cmap=None, mask=None, mask_color='k', grid_units=1, *args, **kwargs)¶ Display a two-dimensional image on a matplotlib figure.
This function serves as an easy replacement for the matplotlib.pyplot.imshow() function. Its signature mostly folows that of matplotlib, with a few minor differences.
- Parameters
- fieldField or ndarray
The field that we want to display. If this is an ndarray, then the parameter grid needs to be supplied. If the field is complex, then it will be automatically fed into
complex_field_to_rgb()
. If the field is a vector field with length 3 or 4, these will be interpreted as an RGB or RGBA field.- gridGrid or None
If a grid is supplied, it will be used instead of the grid of field.
- axmatplotlib axes
The axes which to draw on. If it is not given, the current axes will be used.
- vminscalar
The minimum value on the colorbar. If it is not given, then the minimum value of the field will be used.
- vmaxscalar
The maximum value on the colorbar. If it is not given, then the maximum value of the field will be used.
- aspect[‘auto’, ‘equal’, scalar]
If ‘auto’, changes the image aspect ratio to match that of the axes. If ‘equal’, changes the axes aspect ratio to match that of the image.
- normNormalize
A Normalize instance is used to scale the input to the (0, 1) range for input to the cmap. If it is not given, a linear scale will be used.
- interpolationstring
The interpolation method used. The default is ‘nearest’. Supported values are {‘nearest’, ‘bilinear’}.
- non_linear_axesboolean
If axes are scaled in a non-linear way, for example on a log plot, then imshow_field needs to use a more expensive implementation. This parameter is to indicate that this algorithm needs to be used.
- cmapColormap or None
The colormap with which to plot the image. It is ignored if a complex field or a vector field is supplied.
- maskfield or ndarray
If part of the image needs to be masked, this mask is overlayed on top of the image. This is for example useful when plotting a phase pattern on a certain aperture, which has no meaning outside of the aperture. Masks can be partially translucent, and will be automatically scaled between (0, 1). Zero means invisible, one means visible.
- mask_colorColor
The color of the mask, if it is used.
- grid_unitsscalar or array_like
The size of a unit square. The grid will be scaled by the inverse of this number before plotting. If this is a scalar, an isotropic scaling will be applied.
- Returns
- AxesImage
The produced image.