Image.contour#
- ContourManager.contour(var: ndarray[tuple[Any, ...], dtype[generic]], check: bool = True, **kwargs: Any) QuadContourSet[source]#
Plot a contour plot of a given variable.
The function uses the matplotlib.pyplot.contour function. The function returns None.
- Parameters:
- - alpha: float, default 1.0
Sets the transparency of the contour lines.
- - aspect: {‘auto’, ‘equal’, float}, default ‘auto’
Sets the aspect ratio of the plot. The ‘auto’ keyword is the default option (most likely the plot will be squared). The ‘equal’ keyword will set the same scaling for x and y. A float will fix the ratio between the y-scale and the x-scale (1.0 is the same as ‘equal’).
- - ax: {ax object, ‘old’, None}, default None
The axis where to plot the lines. If None, a new axis is created. If ‘old’, the last considered axis will be used.
- - c: str, default self.color
Determines the contour lines plot. If not defined, the program will loop over an array of 6 color which are different for the most common vision deficiencies.
- - cmap: str, default ‘hot’
Selects the colormap. If not defined, the colormap ‘hot’ will be adopted. Some useful colormaps are: plasma, magma, seismic. Please avoid using colorbars like jjet or rainbow, which are not perceptively uniform and not suited for people with vision deficiencies.
- - cpos: {‘top’,’bottom’,’left’,’right’}, default None
Enables the colorbar (if defined), default position on the right.
- - cscale: {‘linear’,’log’,’symlog’,’twoslope’}, default ‘linear’
Sets the colorbar scale. Default is the linear (‘norm’) scale.
- - extend: {‘neither’,’both’,’min’,’max’}, default ‘neither’
Sets the extension of the triangular colorbar extension.
- - extendrect: bool, default False
If True, the colorbar extension will be rectangular.
- - fontsize: float, default 17.0
Sets the fontsize for all the axis components (only for the current axis).
- - grid: bool, default False
Enables/disables the grid on the plot.
- - labelsize: float, default fontsize
Sets the labels fontsize (which is the same for both labels). The default value corresponds to the value of the keyword ‘fontsize’.
- - levels: np.ndarray
The levels of the contour lines.
- - minorticks: str, default None
If not None enables the minor ticks on the plot (for both grid axes).
- - sharex: Matplotlib axis | False, default False
Shares the x-axis with another axis.
- - sharey: Matplotlib axis | False, default False
Shares the y-axis with another axis.
- - ticksdir: {‘in’, ‘out’}, default ‘in’
Sets the ticks direction. The default option is ‘in’.
- - tickssize: float | bool, default True
Sets the ticks fontsize (which is the same for both grid axes). The default value corresponds to the value of the keyword ‘fontsize’.
- - title: str, default None
Places the title of the plot on top of it.
- - titlepad: float, default 8.0
Sets the distance between the title and the top of the plot
- - titlesize: float, default fontsize
Sets the title fontsize. The default value corresponds to the value of the keyword ‘fontsize’.
- - transpose: True/False, default False
Transposes the variable matrix. Use is not recommended if not really necessary (e.g. in case of highly customized variables and plots).
- - tresh: float, default max(abs(vmin),vmax)*0.01
Sets the threshold for the colormap. If not defined, the threshold will be set to 1% of the maximum absolute value of the variable. The default cases are the following: - twoslope colorscale: sets the limit between the two linear regimes. - symlog: sets the limit between the logaitrhmic and the linear regime.
- - var (not optional): np.ndarray
The variable to be plotted.
- - vmax: float
The maximum value of the colormap.
- - vmin: float
The minimum value of the colormap.
- - x1: 1D array, default ‘Default’
The ‘x’ array.
- - x2: 1D array, default ‘Default’
The ‘y’ array.
- - xrange: [float, float], default [0,1]
Sets the range in the x-direction. If not defined the code will compute the range while plotting the data.
- - xscale: {‘linear’,’log’}, default ‘linear’
If enabled (and different from True), sets automatically the scale on the x-axis. Data in log scale should be used with the keyword ‘log’, while data in linear scale should be used with the keyword ‘linear’.
- - xticks: {[float], None, True}, default True
If enabled (and different from True), sets manually ticks on x-axis. In order to completely remove the ticks the keyword should be used with None.
- - xtickslabels: {[str], None, True}, default True
If enabled (and different from True), sets manually the ticks labels on the x-axis. In order to completely remove the ticks the keyword should be used with None. Note that fixed tickslabels should always correspond to fixed ticks.
- - xtitle: str, default None
Sets and places the label of the x-axis.
- - yrange: [float, float], default [0,1]
Sets the range in the y-direction. If not defined the code will compute the range while plotting the data.
- - yscale: {‘linear’,’log’}, default ‘linear’
If enabled (and different from True), sets automatically the scale on the y-axis. Data in log scale should be used with the keyword ‘log’, while data in linear scale should be used with the keyword ‘linear’.
- - yticks: {[float], None, True}, default True
If enabled (and different from True), sets manually ticks on y-axis. In order to completely remove the ticks the keyword should be used with None.
- - ytickslabels: {[str], None, True}, default True
If enabled (and different from True), sets manually the ticks labels on the y-axis. In order to completely remove the ticks the keyword should be used with None. Note that fixed tickslabels should always correspond to fixed ticks.
- - ytitle: str, default None
Sets and places the label of the y-axis.
- —-
- Returns:
- cnt: LineCollection
The set of contour lines of the given variable.
Examples
Example #1: Plot a contour plot of a variable
>>> I.contour(D.rho, levels=10)