pynbody.plot.generic.make_contour_plot#
- pynbody.plot.generic.make_contour_plot(arr, xs, ys, x_range=None, y_range=None, nlevels=20, logscale=True, xlabel_display_log=False, ylabel_display_log=False, colorbar=False, cmap=None, vmin=None, vmax=None, plot_type='contourf', colorbar_label=None, colorbar_format=None, **kwargs)[source]#
Plot a contour plot of grid arr corresponding to bin centers specified by xs and ys.
Labels the axes and colobar with units taken from x, if available.
Called by
hist2d().Changed in version 2.1:
Added colorbar_label keyword
Added colorbar_format keyword. If provided, this string will be used as the format string for the colorbar. Formerly, the format string was set to ‘%.2e’.
Changed in version 2.0: To simplify the plot interfaces and make them more coherent, the following changes have been made:
It is no longer possible to pass in a filename; instead use the matplotlib
savefigfunction.The legend keyword has been removed; instead use matplotlib
legendThe subplot keyword has been removed; instead ensure that the current matplotlib axes are the ones you want to plot in.
The clear keyword has been removed; instead use the matplotlib
clffunction before calling this function.The scalemin and scalemax keywords have been deprecated in favor of vmin and vmax, for consistency with matplotlib and with other pynbody plotting functions.
The ret_im keyword has been deprecated. If you want to use
imshowinstead ofcontour, set plot_type to ‘image’.
- Parameters:
arr (array-like) – 2D array to plot
xs (array-like) – x-coordinates of bin centres
ys (array-like) – y-coordinates of bin centres
x_range (array-like) – Length-2 array specifies the x range. Default is None, in which case the range is set to the min and max of x.
y_range (array-like) – Length-2 array specifies the y range. Default is None, in which case the range is set to the min and max of y.
xlabel_display_log (boolean, optional) – If True, the x-axis label will indicate that the x values are log-scaled. Other than the axis labelling, this keyword has no effect on the plot.
ylabel_display_log (boolean, optional) – If True, the y-axis label will indicate that the y values are log-scaled. Other than the axis labelling, this keyword has no effect on the plot.
nlevels (int, optional) – Number of levels to use for contours. Default is 20.
logscale (boolean, optional) – If True, use a log-scaled colorbar and log-spaced contours. Default is True.
colorbar (boolean, optional) – If True, draw a colorbar. Default is False.
colorbar_label (str, optional) – If colorbar is True, this string will be used as the label for the colorbar.
colorbar_format (str, optional) – If colorbar is True, this string will be used as the format string for the colorbar.
vmin (float, optional) – Minimum value to use for the color scale. Default is arr.min().
vmax (float, optional) – Maximum value to use for the color scale. Default is arr.max().
cmap (str, optional) – Colormap to use. Default is None, which uses the default colormap.
scalemin (float, optional) – Deprecated. Use vmin instead.
scalemax (float, optional) – Deprecated. Use vmax instead.
ret_im (boolean, optional) – Deprecated. If True, plot_type is set to ‘image’.