Plot Style¶
Contours¶
ContourGroup¶
-
class
tecplot.plot.
ContourGroup
(index, plot)[source]¶ Contouring of a variable using a colormap.
This object controls the style for a specific contour group within a
Frame
. Contour levels, colormap and contour lines are accessed through this class.from os import path import tecplot as tp from tecplot.constant import * # load data exdir = tp.session.tecplot_examples_directory() datafile = path.join(exdir,'2D','polarplot.plt') dataset = tp.data.load_tecplot(datafile) plot = dataset.frame.plot() plot.show_contour = True contour = plot.contour(0) contour.variable = dataset.variable('Mix') contour.colormap_name = 'Magma' # save image to file tp.export_image('polarplot_magma.png')
There are a fixed number of contour groups available for each plot. Others can be enabled and modified by specifying an index other than zero:
>>> contour3 = plot.contour(3) >>> contour3.variable = dataset.variable('U')
Attributes
color_cutoff
ContourColorCutoff
object controlling color cutoff min/max.colormap_filter
ContourColormapFilter
object controlling colormap style properties.colormap_name
The name of the colormap ( str
) to be used.default_num_levels
Default target number ( int
) of levels used when resetting.labels
ContourLabels
object controlling contour line labels.levels
ContourLevels
holding the list of contour levels.lines
ContourLines
object controlling contour line style.variable
The Variable
being contoured.variable_index
Zero-based index of the Variable
being contoured.
-
ContourGroup.
color_cutoff
¶ ContourColorCutoff
object controlling color cutoff min/max.Type: ContourColorCutoff
>>> cutoff = plot.contour(0).color_cutoff >>> cutoff.min = 3.14
-
ContourGroup.
colormap_filter
¶ ContourColormapFilter
object controlling colormap style properties.Type: ContourColormapFilter
>>> plot.contour(0).colormap_filter.reverse = True
-
ContourGroup.
colormap_name
¶ The name of the colormap (
str
) to be used.Type: string
Example:
>>> plot.contour(0).colormap_name = 'Sequential - Yellow/Green/Blue'
-
ContourGroup.
default_num_levels
¶ Default target number (
int
) of levels used when resetting.Type: integer
Example:
>>> plot.contour(0).default_num_levels = 20
-
ContourGroup.
labels
¶ ContourLabels
object controlling contour line labels.Type: ContourLabels
Lines must be turned on through the associated fieldmap object for style changes to be meaningful:
>>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True
-
ContourGroup.
levels
¶ ContourLevels
holding the list of contour levels.Type: ContourLevels
This object controls the values of the contour lines. Values can be added, deleted or overridden completely:
>>> plot.contour(0).levels.reset_to_nice(15)
-
ContourGroup.
lines
¶ ContourLines
object controlling contour line style.Type: ContourLines
Lines must be turned on through the associated fieldmap object for style changes to be meaningful:
>>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).lines.mode = ContourLineMode.DashNegative
-
ContourGroup.
variable
¶ The
Variable
being contoured.The variable must belong to the
Dataset
attached to theFrame
that holds thisContourGroup
. Example usage:>>> plot.contour(0).variable = dataset.variable('P')
-
ContourGroup.
variable_index
¶ Zero-based index of the
Variable
being contoured.>>> plot.contour(0).variable_index = dataset.variable('P').index
The
Dataset
attached to this contour group’sFrame
is used:>>> contour = plot.contour(0) >>> contour_var = frame.dataset.variable(contour.variable_index) >>> contour_var.index == contour.variable_index True
ContourColorCutoff¶
-
class
tecplot.plot.
ContourColorCutoff
(contour)[source]¶ Color-mapped value limits to display.
This lets you specify a range within which contour flooding and multi-colored objects, such as scatter symbols, are displayed.
from os import path import tecplot as tp from tecplot.constant import PlotType, SurfacesToPlot examples_dir = tp.session.tecplot_examples_directory() datafile = path.join(examples_dir,'3D','pyramid.plt') dataset = tp.data.load_tecplot(datafile) plot = tp.active_frame().plot() surfaces = plot.fieldmap(0).surfaces surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces plot.show_contour = True cutoff = plot.contour(0).color_cutoff cutoff.min = 0.5 cutoff.max = 1.0 cutoff.inverted = True tp.export_image('contour_color_cutoff.png')
Attributes
inverted
Cuts values outside the range instead of inside. max
Sets and enables or disables the maximum cutoff value. min
Sets and enables or disables the minimum cutoff value.
-
ContourColorCutoff.
min
¶ Sets and enables or disables the minimum cutoff value.
Type: float
orNone
>>> plot.contour(0).color_cutoff.min = 3.14
ContourColormapFilter¶
-
class
tecplot.plot.
ContourColormapFilter
(contour)[source]¶ Controls how the colormap is rendered for a given contour.
from os import path import tecplot as tp from tecplot.constant import * # load the data exdir = tp.session.tecplot_examples_directory() datafile = path.join(exdir,'2D','MultiPoly2D.plt') ds = tp.data.load_tecplot(datafile) # set plot type to 2D field plot frame = tp.active_frame() frame.plot_type = PlotType.Cartesian2D plot = frame.plot() # show boundary faces and contours surfaces = plot.fieldmap(0).surfaces surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces plot.show_contour = True # by default, contour 0 is the one that's shown, # set the contour's variable, colormap and number of levels contour = plot.contour(0) contour.variable = ds.variable('P') # cycle through the colormap three times and reversed # show a faithful (non-approximate) continuous distribution contour_filter = contour.colormap_filter contour_filter.num_cycles = 3 contour_filter.reversed = True contour_filter.fast_continuous_flood = False contour_filter.distribution = ColorMapDistribution.Continuous # save image to file tp.export_image('poly2d_filtered.png')
Attributes
distribution
Rendering style of the colormap. fast_continuous_flood
Use a fast approximation to continuously flood the colormap. num_cycles
Number of cycles to repeat the colormap. reversed
Reverse the colormap. show_overrides
Enable the colormap overrides in this contour group. zebra_shade
Returns a ContourColormapZebraShade
filtering object.Methods
override
(index)Returns a ContourColormapOverride
object by index.
-
ContourColormapFilter.
show_overrides
¶ Enable the colormap overrides in this contour group.
Type: boolean
The overrides themselves must be turned on as well for this to have an effect on the resulting plot:
>>> contour = plot.contour(0) >>> cmap_filter = contour.colormap_filter >>> cmap_filter.show_overrides = True >>> cmap_filter.override(0).show = True
-
ContourColormapFilter.
distribution
¶ Rendering style of the colormap.
Type: ColorMapDistribution
Possible values:
Banded
- A solid color is assigned for all values within the band between two levels.
Continuous
- The color distribution assigns linearly varying colors to all multi-colored objects or contour flooded regions.
Example:
>>> from tecplot.constant import ColorMapDistribution >>> cmap_filter = plot.contour(0).colormap_filter >>> cmap_filter.distribution = ColorMapDistribution.Banded
-
ContourColormapFilter.
fast_continuous_flood
¶ Use a fast approximation to continuously flood the colormap.
Type: bool
Causes each cell to be flooded using interpolation between the color values at each node. When the transition from a color at one node to another node crosses over the boundary between control points in the color spectrum, fast flooding may produce colors not in the spectrum. Setting this to
False
is slower, but more accurate:>>> cmap_filter = plot.contour(0).colormap_filter >>> cmap_filter.fast_continuous_flood = True
-
ContourColormapFilter.
num_cycles
¶ Number of cycles to repeat the colormap.
Type: integer
>>> plot.contour(0).colormap_filter.num_cycles = 3
-
ContourColormapFilter.
reversed
¶ Reverse the colormap.
Type: bool
>>> plot.contour(0).colormap_filter.reversed = True
-
ContourColormapFilter.
zebra_shade
¶ Returns a
ContourColormapZebraShade
filtering object.Type: ContourColormapZebraShade
Example usage:
>>> zebra = plot.contour(0).colormap_filter.zebra_shade >>> zebra.show = True
-
ContourColormapFilter.
override
(index)[source]¶ Returns a
ContourColormapOverride
object by index.Parameters: index ( int
) – The index of the colormap override object.Returns: ContourColormapOverride
– The class controlling the specific contour colormap override requested by index.Example:
>>> cmap_override = plot.contour(0).colormap_filter.override(0) >>> cmap_override.show = True
ContourColormapOverride¶
-
class
tecplot.plot.
ContourColormapOverride
(index, colormap_filter)[source]¶ Assigns contour bands to specific color.
Specific contour bands can be assigned a unique basic color. This is useful for forcing a particular region to use blue, for example, to designate an area of water. You can define up to 16 color overrides.
from os import path import tecplot as tp from tecplot.constant import * # load the data exdir = tp.session.tecplot_examples_directory() datafile = path.join(exdir,'2D','cstream.plt') ds = tp.data.load_tecplot(datafile) # set plot type to 2D field plot frame = tp.active_frame() frame.plot_type = PlotType.Cartesian2D plot = frame.plot() # show boundary faces and contours surfaces = plot.fieldmap(0).surfaces surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces plot.show_contour = True # by default, contour 0 is the one that's shown, # set the contour's variable, colormap and number of levels contour = plot.contour(0) contour.variable = ds.variable('v3') contour.colormap_name = 'Sequential - Yellow/Green/Blue' contour.levels.reset(10) # turn on colormap overrides for this contour contour_filter = contour.colormap_filter contour_filter.show_overrides = True # turn on override 0, coloring the first 4 levels red contour_override = contour_filter.override(0) contour_override.show = True contour_override.color = Color.Red contour_override.start_level = 0 contour_override.end_level = 4 # save image to file tp.export_image('cstream_contours.png')
Attributes
color
Color which will override the colormap. end_level
Last level to override. show
Include this colormap override when filter is shown. start_level
First level to override.
-
ContourColormapOverride.
show
¶ Include this colormap override when filter is shown.
Type: boolean
Example usage:
>>> colormap_filter = plot.contour(0).colormap_filter >>> cmap_override = colormap_filter.override(0) >>> cmap_override.show = True
-
ContourColormapOverride.
color
¶ Color which will override the colormap.
Type: Color
Example usage:
>>> from tecplot.constant import Color >>> colormap_filter = plot.contour(0).colormap_filter >>> cmap_override = colormap_filter.override(0) >>> cmap_override.color = Color.Blue
ContourColormapZebraShade¶
-
class
tecplot.plot.
ContourColormapZebraShade
(colormap_filter)[source]¶ This filter sets a uniform color for every other band.
Setting the color to
None
turns the bands off and makes them transparent:from os import path import numpy as np import tecplot as tp from tecplot.constant import Color, SurfacesToPlot # load the data examples_dir = tp.session.tecplot_examples_directory() datafile = path.join(examples_dir,'3D','pyramid.plt') dataset = tp.data.load_tecplot(datafile) # show boundary faces and contours plot = tp.active_frame().plot() surfaces = plot.fieldmap(0).surfaces surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces plot.show_contour = True plot.show_shade = False # set zebra filter on and make the zebra contours transparent cont0 = plot.contour(0) zebra = cont0.colormap_filter.zebra_shade zebra.show = True zebra.color = None tp.export_image('contour_zebra.png')
Attributes
color
Color of the zebra shading. show
Show zebra shading in this ContourGroup
.
-
ContourColormapZebraShade.
show
¶ Show zebra shading in this
ContourGroup
.Type: boolean
Example usage:
>>> cmap_filter = plot.contour(0).colormap_filter >>> cmap_filter.zebra_shade.show = True
-
ContourColormapZebraShade.
color
¶ Color of the zebra shading.
Type: Color
orNone
The zebra bands will be transparent when setting the color to
None
:>>> from tecplot.constant import Color >>> # Set the first contour group's zebra shading to be transparent >>> filter0 = plot.contour(0).colormap_filter >>> zebra0 = filter0.zebra_shade >>> zebra0.show = True >>> zebra0.color = None >>> # Make second contour group's zebra shading blue >>> filter1 = plot.contour(1).colormap_filter >>> zebra1 = filter1.zebra_shade >>> zebra1.show = True >>> zebra1.color = Color.Blue
ContourLabels¶
-
class
tecplot.plot.
ContourLabels
(contour)[source]¶ Contour line label style, position and alignment control.
These are labels that identify particular contour levels either by value or optionally, by number starting from one. The plot type must be lines or lines and flood in order to see them:
from os import path import tecplot as tp from tecplot.constant import Color, ContourType, SurfacesToPlot # load the data examples_dir = tp.session.tecplot_examples_directory() datafile = path.join(examples_dir,'3D','pyramid.plt') dataset = tp.data.load_tecplot(datafile) # show boundary faces and contours plot = tp.active_frame().plot() plot.fieldmap(0).contour.contour_type = ContourType.Lines surfaces = plot.fieldmap(0).surfaces surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces plot.show_contour = True # set contour label style contour_labels = plot.contour(0).labels contour_labels.show = True contour_labels.auto_align = False contour_labels.color = Color.Blue contour_labels.background_color = Color.White contour_labels.margin = 20 tp.export_image('contour_labels.png')
Attributes
auto_generate
Automatically generate labels along contour lines. auto_align
Automatically align the labels with the contour lines. background_color
Background fill color behind the text labels. color
Text color of the labels. label_by_level
Use the contour numbers as the label instead of the data value. margin
Spacing around the text and the filled background area. show
Show the contour line labels. spacing
Spacing between labels along the contour lines. step
Number of contour lines from one label to the next.
-
ContourLabels.
show
¶ Show the contour line labels.
Type: bool
Contour lines must be on for this to have any effect:
>>> from tecplot.constant import ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True
-
ContourLabels.
label_by_level
¶ Use the contour numbers as the label instead of the data value.
Type: bool
Contour level numbers start from one when drawn. Example usage:
>>> from tecplot.constant import Color, ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.label_by_level = True
-
ContourLabels.
auto_generate
¶ Automatically generate labels along contour lines.
Type: bool
This causes a new set of contour labels to be created at each redraw:
>>> from tecplot.constant import Color, ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.auto_generate = True
-
ContourLabels.
auto_align
¶ Automatically align the labels with the contour lines.
Type: bool
This causes the flow of the text to be aligned with the contour lines. Otherwise, the labels are aligned with the frame:
>>> from tecplot.constant import ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.auto_align = False
-
ContourLabels.
step
¶ Number of contour lines from one label to the next.
Type: int
This is the number of contour bands between lines that are to be labeled:
>>> from tecplot.constant import ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.step = 4
-
ContourLabels.
spacing
¶ Spacing between labels along the contour lines.
Type: float
This is the distance between each label along each contour line in percentage of the frame height:
>>> from tecplot.constant import ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.spacing = 20
-
ContourLabels.
margin
¶ Spacing around the text and the filled background area.
Type: float
in percentage of the text height.Contour numbers start from one when drawn. Example usage:
>>> from tecplot.constant import Color, ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.background_color = Color.Yellow >>> plot.contour(0).labels.margin = 20
-
ContourLabels.
color
¶ Text color of the labels.
Type: Color
Example:
>>> from tecplot.constant import Color, ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.color Color.Blue
-
ContourLabels.
background_color
¶ Background fill color behind the text labels.
Type: Color
orNone
The background can be filled with a color or disabled (made transparent) by setting this property to
None
:>>> from tecplot.constant import Color, ContourType >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines >>> plot.contour(0).labels.show = True >>> plot.contour(0).labels.background_color = Color.Blue >>> plot.contour(1).labels.show = True >>> plot.contour(1).labels.background_color = None
ContourLevels¶
-
class
tecplot.plot.
ContourLevels
(contour)[source]¶ List of contour level values.
A contour level is a value at which contour lines are drawn, or for banded contour flooding, the border between different colors of flooding. Initially, each contour group consists of approximately 10 levels evenly spaced over the z coordinate in the
Frame
‘sDataset
. These values can be manipulated with theContourLevels
object obtained via theContourGroup.levels
attribute.from os import path import numpy as np import tecplot as tp # load layout examples_dir = tp.session.tecplot_examples_directory() example_layout = path.join(examples_dir,'2D','3element.lpk') tp.load_layout(example_layout) frame = tp.active_frame() levels = frame.plot().contour(0).levels levels.reset_levels(np.linspace(55000,115000,61)) # save image to file tp.export_image('3element_adjusted_levels.png')
Note
The streamtraces in the plot above is a side-effect of settings in layout file used. For more information about streamtraces, see the
plot.Streamtrace
class reference.Methods
add
(*values)Adds new levels to the existing list. delete_nearest
(value)Removes the level closest to the specified value. delete_range
(min_value, max_value)Inclusively, deletes all levels within a specified range. reset
([num_levels])Resets the levels to the number specified. reset_levels
(*values)Resets the levels to the values specified. reset_to_nice
([num_levels])Approximately resets the levels to the number specified.
-
ContourLevels.
reset
(num_levels=15)[source]¶ Resets the levels to the number specified.
Parameters: num_levels ( integer
) – Number of levels. (default: 10)This will reset the contour levels to a set of evenly distributed values spanning the entire range of the currently selected contouring variable:
>>> plot.contour(0).levels.reset(30)
-
ContourLevels.
reset_levels
(*values)[source]¶ Resets the levels to the values specified.
Parameters: *values ( floats
) – The level values to be added to theContourGroup
.This method replaces the current set of contour levels with a new set. Here, we set the levels to go from 0 to 100 in steps of 5:
>>> plot.contour(0).levels.reset_levels(*range(0,101,5))
-
ContourLevels.
reset_to_nice
(num_levels=15)[source]¶ Approximately resets the levels to the number specified.
Parameters: num_levels ( integer
) – Approximate number of levels to create. (default: 10)This will reset the contour levels to a set of evenly distributed values that approximately spans the range of the currently selected contouring variable. Exact range and number of levels will be adjusted to make the contour levels have “nice” values:
>>> plot.contour(0).levels.reset_to_nice(50)
-
ContourLevels.
add
(*values)[source]¶ Adds new levels to the existing list.
Parameters: *values ( floats
) – The level values to be added to theContourGroup
.The values added are inserted into the list of levels in ascending order:
>>> levels = plot.contour(0).levels >>> list(levels) [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] >>> levels.add(3.14159) >>> list(levels) [0.0, 1.0, 2.0, 3.0, 3.14159, 4.0, 5.0]
-
ContourLevels.
delete_nearest
(value)[source]¶ Removes the level closest to the specified value.
Parameters: value ( float
) – Value of the level to remove.This method deletes the contour level with the value nearest the supplied value:
>>> plot.contour(0).levels.delete_nearest(3.14)
-
ContourLevels.
delete_range
(min_value, max_value)[source]¶ Inclusively, deletes all levels within a specified range.
Parameters: This method deletes all contour levels between the specified minimum and maximum values of the contour variable (inclusive):
>>> plot.contour(0).levels.delete_range(0.5, 1.5)
ContourLines¶
-
class
tecplot.plot.
ContourLines
(contour)[source]¶ Contour line style.
This object sets the style of the contour lines once turned on.
from os import path import tecplot as tp from tecplot.constant import (ContourLineMode, ContourType, SurfacesToPlot) # load the data examples_dir = tp.session.tecplot_examples_directory() datafile = path.join(examples_dir,'3D','pyramid.plt') dataset = tp.data.load_tecplot(datafile) # show boundary faces and contours plot = tp.active_frame().plot() plot.fieldmap(0).contour.contour_type = ContourType.Lines surfaces = plot.fieldmap(0).surfaces surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces plot.show_contour = True # set contour line style contour_lines = plot.contour(0).lines contour_lines.mode = ContourLineMode.SkipToSolid contour_lines.step = 4 contour_lines.pattern_length = 2 tp.export_image('contour_lines.png')
Attributes
mode
Type of lines to draw on the plot ( ContourLineMode
).pattern_length
Length of dashed lines and space between dashes ( float
).step
Number of lines to step for SkipToSolid
line mode (int
).
-
ContourLines.
mode
¶ Type of lines to draw on the plot (
ContourLineMode
).Type: ContourLineMode
Possible values:
UseZoneLineType
- For each zone, draw the contour lines using the line pattern
and pattern length specified in the
FieldmapContour
for the parent Fieldmaps. If you are adding contour lines to polyhedral zones, the patterns will not be continuous from one cell to the next and the pattern will restart at every cell boundary. SkipToSolid
- Draw dashed lines between each pair of solid lines which are
spaced out by the
ContourLines.step
property. This will override any line pattern or thickness setting in the parent Fieldmaps‘sFieldmapContour
object. DashNegative
- Draw lines of positive contour variable value as solid lines
and lines of negative contour variable value as dashed lines.
This will override any line pattern or thickness setting in the
parent Fieldmaps‘s
FieldmapContour
object.
Example:
>>> from tecplot.constant import ContourLineMode >>> lines = plot.contour(0).lines >>> lines.mode = ContourLineMode.DashNegative
-
ContourLines.
step
¶ Number of lines to step for
SkipToSolid
line mode (int
).Type: int
Example:
>>> from tecplot.constant import ContourLineMode >>> lines = plot.contour(0).lines >>> lines.mode = ContourLineMode.SkipToSolid >>> lines.step = 5
-
ContourLines.
pattern_length
¶ Length of dashed lines and space between dashes (
float
).Type: float
The length is in percentage of the frame height:
>>> from tecplot.constant import ContourLineMode >>> lines = plot.contour(0).lines >>> lines.mode = ContourLineMode.SkipToSolid >>> lines.step = 5 >>> lines.pattern_length = 5