ContourGenerator¶
- class contourpy.ContourGenerator¶
Abstract base class for contour generator classes, defining the interface that they all implement.
- class property default_fill_type¶
Return the default
FillTypeused by this algorithm.
- class property default_line_type¶
Return the default
LineTypeused by this algorithm.
- property chunk_count¶
Return tuple of (y, x) chunk counts.
- property chunk_size¶
Return tuple of (y, x) chunk sizes.
- property corner_mask¶
Return whether
corner_maskis set or not.
- filled(self: contourpy._contourpy.ContourGenerator, lower_level: float, upper_level: float) tuple¶
Calculate and return filled contours between two levels.
- Parameters:
lower_level (float) – Lower z-level of the filled contours, cannot be
np.nan.upper_level (float) – Upper z-level of the filled contours, cannot be
np.nan.
- Returns:
Filled contour polygons as nested sequences of numpy arrays. The exact format is determined by the
fill_typeused by theContourGeneratorand the options are explained at Fill type.
Raises a
ValueErroriflower_level >= upper_levelor iflower_levelorupper_levelarenp.nan.To return filled contours below a
levelusefilled(-np.inf, level). To return filled contours above alevelusefilled(level, np.inf)
- lines(self: contourpy._contourpy.ContourGenerator, level: float) Sequence¶
Calculate and return contour lines at a particular level.
- Parameters:
level (float) – z-level to calculate contours at.
- Returns:
Contour lines (open line strips and closed line loops) as nested sequences of numpy arrays. The exact format is determined by the
line_typeused by theContourGeneratorand the options are explained at Line type.
levelmay benp.nan,np.infor-np.inf; they all return the same result which is an empty line set.
- multi_filled(self: contourpy._contourpy.ContourGenerator, levels: numpy.ndarray[numpy.float64]) list¶
Calculate and return filled contours between multiple pairs of adjacent levels.
- Parameters:
levels (array-like of floats) – z-levels to calculate filled contours between. There must be at least 2 levels, they cannot be NaN, and each level must be larger than the previous level.
- Returns:
List of filled contours, one per pair of levels. The length of the returned list is one less than
len(levels). The format of returned contours is determined by thefill_typeused by theContourGeneratorand the options are explained at Fill type.
Raises a
ValueErroriflevelsare not increasing, or contain a NaN, or there are fewer than 2levels.Calling:
ret = cont_gen.multi_filled(levels)
is equivalent to:
ret = [cont_gen.filled(lower, upper) for lower, upper in zip(levels[:-1], levels[1:])]
Added in version 1.3.0.
- multi_lines(self: contourpy._contourpy.ContourGenerator, levels: numpy.ndarray[numpy.float64]) list¶
Calculate and return contour lines at multiple levels.
- Parameters:
levels (array-like of floats) – z-levels to calculate contours at.
- Returns:
List of contour lines, one per level. The format of returned lines is determined by the
line_typeused by theContourGeneratorand the options are explained at Line type.
Calling:
ret = cont_gen.multi_lines(levels)
is equivalent to:
ret = [cont_gen.lines(level) for level in levels]
Added in version 1.3.0.
- property quad_as_tri¶
Return whether
quad_as_triis set or not.
- static supports_corner_mask() bool¶
Return whether this algorithm supports
corner_mask.
- static supports_fill_type(fill_type: contourpy._contourpy.FillType) bool¶
Return whether this algorithm supports a particular
FillType.
- static supports_line_type(line_type: contourpy._contourpy.LineType) bool¶
Return whether this algorithm supports a particular
LineType.
- static supports_quad_as_tri() bool¶
Return whether this algorithm supports
quad_as_tri.
- static supports_threads() bool¶
Return whether this algorithm supports the use of threads.
- static supports_z_interp() bool¶
Return whether this algorithm supports
z_interpvalues other thanZInterp.Linearwhich all support.
- property thread_count¶
Return the number of threads used.
- property z_interp¶
Return the
ZInterp.
- class contourpy.Mpl2005ContourGenerator¶
Bases:
ContourGeneratorContourGenerator corresponding to
name="mpl2005".This is the original 2005 Matplotlib algorithm. Does not support any of
corner_mask,quad_as_tri,threadsorz_interp. Only supportsline_type=LineType.SeparateCodeandfill_type=FillType.OuterCode. Only supports chunking for filled contours, not contour lines.Warning
This algorithm is in
contourpyfor historic comparison. No new features or bug fixes will be added to it, except for security-related bug fixes.
- class contourpy.Mpl2014ContourGenerator¶
Bases:
ContourGeneratorContourGenerator corresponding to
name="mpl2014".This is the 2014 Matplotlib algorithm, a replacement of the original 2005 algorithm that added
corner_maskand made the code more maintainable. Only supportscorner_mask, does not supportquad_as_tri,threadsorz_interp. Only supportsline_type=LineType.SeparateCodeandfill_type=FillType.OuterCode.Warning
This algorithm is in
contourpyfor historic comparison. No new features or bug fixes will be added to it, except for security-related bug fixes.
- class contourpy.SerialContourGenerator¶
Bases:
ContourGeneratorContourGenerator corresponding to
name="serial", the default algorithm forcontourpy.Supports
corner_mask,quad_as_triandz_interpbut notthreads. Supports all options forline_typeandfill_type.
- class contourpy.ThreadedContourGenerator¶
Bases:
ContourGeneratorContourGenerator corresponding to
name="threaded", the multithreaded version ofSerialContourGenerator.Supports
corner_mask,quad_as_triandz_interpandthreads. Supports all options forline_typeandfill_type.