spectrochempy.plot_contourf#

plot_contourf(dataset, **kwargs)[source]#

Plot a 2D dataset as a filled contour (image-like) plot.

This is the canonical geometry-based name for image plots. Uses high-resolution filled contours (500 levels by default).

Parameters:
  • dataset (:class:~spectrochempy.ddataset.nddataset.NDDataset) – Source of data to plot.

  • method (str, optional, default: auto-detected from data dimensionality) – Name of plotting method to use. If None, method is chosen based on data dimensionality.

    2D plotting methods:

    • lines : Stacked plot

    • contour : Contour plot

    • contourf : Filled contour (image-like) plot (canonical)

    • surface : Surface plot

    • waterfall : Waterfall plot

  • **kwargs – Additional matplotlib / plotting keyword arguments.

Other Parameters:
  • ax (Axe, optional) – Axe where to plot. If not specified, create a new one.

  • clear (bool, optional, default: True) – If false, hold the current figure and ax until a new plot is performed.

  • color or c (color, optional, default: auto) – color of the line.

  • colorbar (bool, optional, default: True) – Show colorbar (2D plots only).

  • commands (str,) – matplotlib commands to be executed.

  • data_only (bool, optional, default: False) – Only the plot is done. No addition of axes or label specifications.

  • dpi (int, optional) – the number of pixel per inches.

  • figsize (tuple, optional, default is (3.4, 1.7)) – figure size.

  • fontsize (int, optional) – The font size in pixels, default is 10 (or read from preferences).

  • imag (bool, optional, default: False) – Show imaginary component for complex data. By default the real component is displayed.

  • linestyle or ls (str, optional, default: auto) – line style definition.

  • linewidth or lw (float, optional, default: auto) – line width.

  • marker, m (str, optional, default: auto) – marker type for scatter plot. If marker != “” then the scatter type of plot is chosen automatically.

  • markeredgecolor or mec (color, optional)

  • markeredgewidth or mew (float, optional)

  • markerfacecolor or mfc (color, optional)

  • markersize or ms (float, optional)

  • markevery (None or int)

  • modellinestyle or modls (str) – line style of the model.

  • offset (float) – offset of the model individual lines.

  • output (str or pathlib.Path, optional) – Destination file for the completed figure. Saving and display use the same lifecycle as dataset.plot(method=...).

  • plot_model (Bool,) – plot model data if available.

  • plottitle (bool, optional, default: False) – Use the name of the dataset as title. Works only if title is not defined

  • projections (bool, str or sequence of str, optional) – For contour/contourf plots, add marginal panels retaining the named dataset dimensions. True selects both dimensions, False disables them. A dimension on the horizontal axis produces a top panel; a dimension on the vertical axis produces a right panel. Dimension names retain their meaning after transposition. When omitted, use the show_projections and show_projection_x/y preferences.

  • projection_reducer ({‘sum’, ‘mean’, ‘max’}, default: ‘sum’) – Reduce over the other dimension, excluding masked and non-finite data. This is a pointwise reduction, not a coordinate-weighted integral.

  • projection_data (mapping, optional) – Map a retained dimension to a reference NDDataset or list of them. A 2D reference contributes one curve per row. References replace the calculated projection for that dimension. Their coordinates may have different sampling, but must have compatible units and overlap the map. Coordinates are converted without interpolation or input mutation. Without an explicit selection, supplied reference dimensions are enabled.

  • projection_kwargs (mapping, optional) – Per-dimension dictionaries accepting color, linestyle, linewidth, labels, legend (bool or location), intensity_label and title. Styles may be scalar or one per reference curve; labels must be one per curve.

  • projection_size (float, default: 0.25) – Marginal size as a fraction of the corresponding main axes size.

  • projection_pad (float, default: 0.12) – Gap between the map and each marginal, in inches.

  • positive_color, negative_color (color, optional) – Use a two-color, zero-centered palette for signed contours. An omitted counterpart defaults to red (positive) or blue (negative). The colorbar, if requested, uses the same sign palette and symmetric amplitude range. These colors take precedence over cmap/norm. Filled contours include a zero boundary when the specified levels span both signs.

  • positive_linestyle, negative_linestyle (str, optional) – Contour line style for each sign; otherwise use linestyle.

  • diagonal (bool, default: False) – Add a dotted diagonal within the shared coordinate range. Axis units must match.

  • return_dict (bool, default: False) – Return a dictionary with fig and axes instead of the main axes. The axes mapping contains main and any top/right marginal axes.

  • reverse (bool or None [optional, default=None/False) – In principle, coordinates run from left to right, except for wavenumbers (e.g., FTIR spectra) or ppm (e.g., NMR), that spectrochempy will try to guess. But if reverse is set, then this is the setting which will be taken into account.

  • show_complex (bool, optional, default: False) – Show both real and imaginary component for complex data. By default only the real component is displayed.

  • show_mask (bool, optional) – Should we display the mask using colored area.

  • show_z (bool, optional, default: True) – should we show the vertical axis.

  • show_zero (bool, optional) – show the zero basis.

  • style (str, optional, default: scp.preferences.style (scpy)) – Matplotlib stylesheet (use available_style to get a list of available styles for plotting.

  • title (str) – Title of the plot (or subplot) axe.

  • transposed (bool, optional, default: False) – Transpose the data before plotting (2D plots only).

  • twinx (Axes, optional, default: None) – If this is not None, then a twin axes will be created with a common x dimension.

  • uselabel_x (bool, optional) – use x coordinate label as x tick labels

  • vshift (float, optional) – vertically shift the line from its baseline.

  • xlim (tuple, optional) – limit on the horizontal axis.

  • xlabel (str, optional) – label on the horizontal axis.

  • x_reverse (bool, optional, default: False) – reverse the x axis. Equivalent to reverse.

  • ylabel or zlabel (str, optional) – label on the vertical axis.

  • ylim or zlim (tuple, optional) – limit on the vertical axis.

  • y_reverse (bool, optional, default: False) – reverse the y axis (2D plot only).

  • equal_aspect (bool, optional, default: False) – If True and X/Y units are compatible, enforce metric scaling (square pixels). This ensures 1 unit in X equals 1 unit in Y.

Returns:

Matplotlib Axes, dict or None – The main axes, or a fig/axes dictionary when return_dict=True.