pytecplot 1.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytecplot-1.5.2.dist-info/LICENSE.html +77 -0
- pytecplot-1.5.2.dist-info/METADATA +508 -0
- pytecplot-1.5.2.dist-info/RECORD +97 -0
- pytecplot-1.5.2.dist-info/WHEEL +5 -0
- pytecplot-1.5.2.dist-info/top_level.txt +1 -0
- tecplot/__init__.py +94 -0
- tecplot/annotation/__init__.py +7 -0
- tecplot/annotation/annotation.py +223 -0
- tecplot/annotation/geometry.py +369 -0
- tecplot/annotation/georeference.py +33 -0
- tecplot/annotation/image.py +185 -0
- tecplot/annotation/iter.py +105 -0
- tecplot/annotation/polyline.py +381 -0
- tecplot/annotation/text.py +744 -0
- tecplot/constant.py +401 -0
- tecplot/data/__init__.py +34 -0
- tecplot/data/array.py +645 -0
- tecplot/data/create.py +1 -0
- tecplot/data/dataset.py +1809 -0
- tecplot/data/extract.py +544 -0
- tecplot/data/face_neighbors.py +494 -0
- tecplot/data/facemap.py +814 -0
- tecplot/data/load.py +2075 -0
- tecplot/data/nodemap.py +577 -0
- tecplot/data/operate.py +928 -0
- tecplot/data/query.py +334 -0
- tecplot/data/save.py +343 -0
- tecplot/data/variable.py +280 -0
- tecplot/data/zone.py +841 -0
- tecplot/exception.py +201 -0
- tecplot/export/__init__.py +13 -0
- tecplot/export/animation.py +521 -0
- tecplot/export/export_setup.py +318 -0
- tecplot/export/image.py +577 -0
- tecplot/export/print_setup.py +218 -0
- tecplot/export/time_animation.py +607 -0
- tecplot/extension/__init__.py +14 -0
- tecplot/extension/ipython.py +68 -0
- tecplot/layout/__init__.py +20 -0
- tecplot/layout/frame.py +1285 -0
- tecplot/layout/layout.py +488 -0
- tecplot/layout/page.py +541 -0
- tecplot/legend/__init__.py +4 -0
- tecplot/legend/contour_legend.py +516 -0
- tecplot/legend/legend.py +141 -0
- tecplot/legend/line_legend.py +66 -0
- tecplot/legend/rgb_coloring_legend.py +291 -0
- tecplot/legend/scatter_legend.py +136 -0
- tecplot/macro.py +339 -0
- tecplot/plot/__init__.py +62 -0
- tecplot/plot/axes.py +881 -0
- tecplot/plot/axis.py +1350 -0
- tecplot/plot/blanking.py +584 -0
- tecplot/plot/contour.py +1302 -0
- tecplot/plot/effects.py +162 -0
- tecplot/plot/fieldmap.py +2159 -0
- tecplot/plot/grid.py +758 -0
- tecplot/plot/isosurface.py +1167 -0
- tecplot/plot/labels.py +338 -0
- tecplot/plot/linemap.py +1905 -0
- tecplot/plot/linking.py +489 -0
- tecplot/plot/plot.py +1791 -0
- tecplot/plot/rgb_coloring.py +281 -0
- tecplot/plot/scatter.py +396 -0
- tecplot/plot/slice.py +1544 -0
- tecplot/plot/streamtrace.py +1949 -0
- tecplot/plot/symbol.py +567 -0
- tecplot/plot/ticks.py +666 -0
- tecplot/plot/title.py +380 -0
- tecplot/plot/vector.py +679 -0
- tecplot/plot/view.py +868 -0
- tecplot/session/__init__.py +112 -0
- tecplot/session/aux_data.py +276 -0
- tecplot/session/config.py +92 -0
- tecplot/session/session.py +425 -0
- tecplot/session/state_changed.py +225 -0
- tecplot/session/style.py +504 -0
- tecplot/tecutil/__init__.py +16 -0
- tecplot/tecutil/arglist.py +230 -0
- tecplot/tecutil/captured_output.py +177 -0
- tecplot/tecutil/constant.py +1312 -0
- tecplot/tecutil/index_set.py +118 -0
- tecplot/tecutil/lock.py +36 -0
- tecplot/tecutil/message_pb2.py +39 -0
- tecplot/tecutil/preamble.py +54 -0
- tecplot/tecutil/stringlist.py +114 -0
- tecplot/tecutil/sv.py +1662 -0
- tecplot/tecutil/tecutil.py +12402 -0
- tecplot/tecutil/tecutil_client.py +627 -0
- tecplot/tecutil/tecutil_connector.py +937 -0
- tecplot/tecutil/tecutil_rpc.py +6845 -0
- tecplot/tecutil/util.py +332 -0
- tecplot/text/__init__.py +3 -0
- tecplot/text/font.py +224 -0
- tecplot/text/label_format.py +374 -0
- tecplot/text/textbox.py +106 -0
- tecplot/version.py +41 -0
tecplot/plot/linemap.py
ADDED
|
@@ -0,0 +1,1905 @@
|
|
|
1
|
+
from builtins import int, str, super
|
|
2
|
+
|
|
3
|
+
import collections
|
|
4
|
+
import ctypes
|
|
5
|
+
import textwrap
|
|
6
|
+
|
|
7
|
+
from collections.abc import Iterable
|
|
8
|
+
|
|
9
|
+
from ..tecutil import _tecutil, sv
|
|
10
|
+
from ..constant import *
|
|
11
|
+
from ..exception import *
|
|
12
|
+
from .. import session, tecutil
|
|
13
|
+
from . import symbol
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LinemapBars(session.SubStyle):
|
|
17
|
+
"""Bar chart style control.
|
|
18
|
+
|
|
19
|
+
A bar chart is an XY Line plot that uses vertical or horizontal bars placed
|
|
20
|
+
along an axis to represent data points. Changing the function dependency of
|
|
21
|
+
the linemap with `XYLinemap.function_dependency` controls the direction of
|
|
22
|
+
the bars. By default, all mappings use :math:`y = f(x)` and appear as
|
|
23
|
+
vertical bar charts. Setting *y* to be the independent variable will cause
|
|
24
|
+
the bars to be horizontal:
|
|
25
|
+
|
|
26
|
+
.. code-block:: python
|
|
27
|
+
:emphasize-lines: 12,16-21
|
|
28
|
+
|
|
29
|
+
from os import path
|
|
30
|
+
import tecplot as tp
|
|
31
|
+
from tecplot.constant import PlotType, Color
|
|
32
|
+
|
|
33
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
34
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
35
|
+
dataset = tp.data.load_tecplot(infile)
|
|
36
|
+
|
|
37
|
+
frame = tp.active_frame()
|
|
38
|
+
frame.plot_type = PlotType.XYLine
|
|
39
|
+
plot = frame.plot()
|
|
40
|
+
plot.show_bars = True
|
|
41
|
+
|
|
42
|
+
lmap = plot.linemap(0)
|
|
43
|
+
|
|
44
|
+
bars = lmap.bars
|
|
45
|
+
bars.show = True
|
|
46
|
+
bars.size = 0.6*(100 / dataset.zone(0).num_points)
|
|
47
|
+
bars.fill_color = Color.Red
|
|
48
|
+
bars.line_color = Color.Red
|
|
49
|
+
bars.line_thickness = 0.01
|
|
50
|
+
|
|
51
|
+
tp.export.save_png('linemap_bars.png', 600, supersample=3)
|
|
52
|
+
|
|
53
|
+
.. figure:: /_static/images/linemap_bars.png
|
|
54
|
+
:width: 300px
|
|
55
|
+
:figwidth: 300px
|
|
56
|
+
"""
|
|
57
|
+
def __init__(self, linemap):
|
|
58
|
+
self.linemap = linemap
|
|
59
|
+
super().__init__(linemap, sv.BARCHARTS)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def show(self):
|
|
63
|
+
"""`bool`: Display bars on the plot for this :ref:`Linemap`.
|
|
64
|
+
|
|
65
|
+
The parent plot object must have bars enabled as well::
|
|
66
|
+
|
|
67
|
+
>>> plot.show_bars = True
|
|
68
|
+
>>> plot.linemap(0).bars.show = True
|
|
69
|
+
"""
|
|
70
|
+
return self._get_style(bool, sv.SHOW)
|
|
71
|
+
|
|
72
|
+
@show.setter
|
|
73
|
+
def show(self, value):
|
|
74
|
+
self._set_style(bool(value), sv.SHOW)
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def size(self):
|
|
78
|
+
"""`float` (percentange of `Frame <layout.Frame>` width): Width of the bars.
|
|
79
|
+
|
|
80
|
+
Example usage::
|
|
81
|
+
|
|
82
|
+
>>> plot.linemap(0).bars.size = 0.10
|
|
83
|
+
"""
|
|
84
|
+
return self._get_style(float, sv.SIZE)
|
|
85
|
+
|
|
86
|
+
@size.setter
|
|
87
|
+
def size(self, value):
|
|
88
|
+
self._set_style(float(value), sv.SIZE)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def fill_mode(self):
|
|
92
|
+
"""`FillMode`: fill mode for the bars.
|
|
93
|
+
|
|
94
|
+
Possible values: `FillMode.UseSpecificColor`, `FillMode.UseLineColor`,
|
|
95
|
+
`FillMode.UseBackgroundColor` or `FillMode.None_`.
|
|
96
|
+
|
|
97
|
+
Example usage::
|
|
98
|
+
|
|
99
|
+
>>> from tecplot.constant import FillMode
|
|
100
|
+
>>> bars = plot.linemap(0).bars
|
|
101
|
+
>>> bars.fill_mode = FillMode.UseBackgroundColor
|
|
102
|
+
"""
|
|
103
|
+
return self._get_style(FillMode, sv.FILLMODE)
|
|
104
|
+
|
|
105
|
+
@fill_mode.setter
|
|
106
|
+
def fill_mode(self, value):
|
|
107
|
+
self._set_style(FillMode(value), sv.FILLMODE)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def fill_color(self):
|
|
111
|
+
"""`Color` or `ContourGroup`.: Fill color of the bars.
|
|
112
|
+
|
|
113
|
+
The ``fill_mode`` attribute must be set to
|
|
114
|
+
`FillMode.UseSpecificColor`::
|
|
115
|
+
|
|
116
|
+
>>> from tecplot.constant import Color, FillMode
|
|
117
|
+
>>> bars = plot.linemap(0).bars
|
|
118
|
+
>>> bars.fill_mode = FillMode.UseSpecificColor
|
|
119
|
+
>>> bars.fill_color = Color.Red
|
|
120
|
+
"""
|
|
121
|
+
color = self._get_style(Color, sv.FILLCOLOR)
|
|
122
|
+
return tecutil.color_spec(color, self.linemap.plot)
|
|
123
|
+
|
|
124
|
+
@fill_color.setter
|
|
125
|
+
def fill_color(self, value):
|
|
126
|
+
self._set_style(tecutil.color_spec(value), sv.FILLCOLOR)
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def line_color(self):
|
|
130
|
+
"""`Color`: Edge line color of the bars.
|
|
131
|
+
|
|
132
|
+
Example usage::
|
|
133
|
+
|
|
134
|
+
>>> from tecplot.constant import Color
|
|
135
|
+
>>> plot.linemap(0).bars.line_color = Color.Red
|
|
136
|
+
"""
|
|
137
|
+
return self._get_style(Color, sv.COLOR)
|
|
138
|
+
|
|
139
|
+
@line_color.setter
|
|
140
|
+
def line_color(self, value):
|
|
141
|
+
self._set_style(Color(value), sv.COLOR)
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def line_thickness(self):
|
|
145
|
+
"""`float`: Edge line thickness of the bars.
|
|
146
|
+
|
|
147
|
+
Example usage::
|
|
148
|
+
|
|
149
|
+
>>> plot.linemap(0).bars.line_thickness = 0.1
|
|
150
|
+
"""
|
|
151
|
+
return self._get_style(float, sv.LINETHICKNESS)
|
|
152
|
+
|
|
153
|
+
@line_thickness.setter
|
|
154
|
+
def line_thickness(self, value):
|
|
155
|
+
self._set_style(float(value), sv.LINETHICKNESS)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class LinemapCurve(session.SubStyle):
|
|
159
|
+
"""Curve-fitting of the line.
|
|
160
|
+
|
|
161
|
+
This class controls how the line is to be drawn between data points. By
|
|
162
|
+
default, the `CurveType.LineSeg` option is used and straight lines are
|
|
163
|
+
used. Setting `curve_type` to a fit type or spline type will replace the
|
|
164
|
+
line segments with a smooth curve:
|
|
165
|
+
|
|
166
|
+
.. code-block:: python
|
|
167
|
+
:emphasize-lines: 35-49
|
|
168
|
+
|
|
169
|
+
import numpy as np
|
|
170
|
+
from os import path
|
|
171
|
+
import tecplot as tp
|
|
172
|
+
from tecplot.constant import PlotType, CurveType
|
|
173
|
+
|
|
174
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
175
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
176
|
+
dataset = tp.data.load_tecplot(infile)
|
|
177
|
+
dataset.add_variable('Weight')
|
|
178
|
+
|
|
179
|
+
# convert error to weighting to be used for fitting below
|
|
180
|
+
# This converts the error to (1 / error)
|
|
181
|
+
# and normalizes to the range [1,100]
|
|
182
|
+
zone = dataset.zone('ZONE 1')
|
|
183
|
+
err1 = zone.values('Error 1')
|
|
184
|
+
wvar = zone.values('Weight')
|
|
185
|
+
err = err1.as_numpy_array()
|
|
186
|
+
sigma = 1. / err
|
|
187
|
+
dsigma = sigma.max() - sigma.min()
|
|
188
|
+
sigma = (99 * (sigma - sigma.min()) / dsigma) + 1
|
|
189
|
+
wvar[:] = sigma
|
|
190
|
+
|
|
191
|
+
frame = tp.active_frame()
|
|
192
|
+
frame.plot_type = PlotType.XYLine
|
|
193
|
+
plot = frame.plot()
|
|
194
|
+
|
|
195
|
+
lmaps = plot.linemaps()
|
|
196
|
+
|
|
197
|
+
lmaps.show = True
|
|
198
|
+
lmaps.x_variable = dataset.variable(0)
|
|
199
|
+
|
|
200
|
+
for lmap, var in zip(lmaps, list(dataset.variables())[1:4]):
|
|
201
|
+
lmap.y_variable = var
|
|
202
|
+
|
|
203
|
+
curves = [lmap.curve for lmap in plot.linemaps()]
|
|
204
|
+
|
|
205
|
+
curves[0].curve_type = CurveType.PolynomialFit
|
|
206
|
+
curves[0].num_points = 1000
|
|
207
|
+
curves[0].polynomial_order = 10
|
|
208
|
+
|
|
209
|
+
curves[1].curve_type = CurveType.PowerFit
|
|
210
|
+
curves[1].use_fit_range = True
|
|
211
|
+
curves[1].fit_range = 4,8
|
|
212
|
+
curves[1].weight_variable = dataset.variable('Weight')
|
|
213
|
+
curves[1].use_weight_variable = True
|
|
214
|
+
|
|
215
|
+
curves[2].curve_type = CurveType.Spline
|
|
216
|
+
curves[2].clamp_spline = True
|
|
217
|
+
curves[2].spline_derivative_at_ends = 0,0
|
|
218
|
+
|
|
219
|
+
tp.export.save_png('linemap_curve.png', 600, supersample=3)
|
|
220
|
+
|
|
221
|
+
.. figure:: /_static/images/linemap_curve.png
|
|
222
|
+
:width: 300px
|
|
223
|
+
:figwidth: 300px
|
|
224
|
+
"""
|
|
225
|
+
def __init__(self, linemap):
|
|
226
|
+
self.linemap = linemap
|
|
227
|
+
super().__init__(linemap, sv.CURVES)
|
|
228
|
+
|
|
229
|
+
@property
|
|
230
|
+
def curve_type(self):
|
|
231
|
+
"""`CurveType`: Type of curve to draw or fit.
|
|
232
|
+
|
|
233
|
+
Possible values: `LineSeg`, `PolynomialFit`, `EToRFit`, `PowerFit`,
|
|
234
|
+
`Spline`, `ParaSpline`.
|
|
235
|
+
|
|
236
|
+
`CurveType.LineSeg` (line segment, no curve-fit)
|
|
237
|
+
A series of linear segments connect adjacent data points. In XY
|
|
238
|
+
Line plots, these will be line segments.
|
|
239
|
+
`CurveType.PolynomialFit`
|
|
240
|
+
A polynomial of order `LinemapCurve.polynomial_order` is fit to the
|
|
241
|
+
data points where :math:`1 <= N <= 10`. :math:`N = 1` is a
|
|
242
|
+
straight-line fit.
|
|
243
|
+
`CurveType.EToRFit` (exponential curve-fit)
|
|
244
|
+
An exponential curve-fit that finds the best curve of the form
|
|
245
|
+
:math:`Y = e^{b\cdot X+c}` which is equivalent to :math:`Y = a\cdot
|
|
246
|
+
e^{b\cdot X}`, where :math:`a = e^c`. To use this curve type,
|
|
247
|
+
*Y*-values for this variable must be all positive or all negative.
|
|
248
|
+
If the function dependency is set to :math:`X = f(Y)` all
|
|
249
|
+
*X*-values must be all positive or all negative.
|
|
250
|
+
`CurveType.PowerFit`
|
|
251
|
+
A power curve fit that finds the best curve of the form :math:`Y =
|
|
252
|
+
e^{b \cdot \ln X + c}` which is equivalent to :math:`Y = a\cdot X^b`
|
|
253
|
+
, where :math:`a = e^c`. To use this curve type, *Y*-values for this
|
|
254
|
+
variable must be all positive or all negative; *X*-values must be
|
|
255
|
+
all positive. If the function dependency is set to :math:`X =
|
|
256
|
+
f(Y)`, *X*-values must be all positive or all negative, and the
|
|
257
|
+
*Y*-values must all be positive.
|
|
258
|
+
`CurveType.Spline`
|
|
259
|
+
A smooth curve is generated that goes through every point. The
|
|
260
|
+
spline is drawn through the data points after sorting the points
|
|
261
|
+
into increasing values of the independent variable, resulting in a
|
|
262
|
+
single-valued function of the independent variable. The spline may
|
|
263
|
+
be clamped or free. With a clamped spline, you supply the
|
|
264
|
+
derivative of the function at each end point; with a non-clamped
|
|
265
|
+
(natural or free) spline, these derivatives are determined for you.
|
|
266
|
+
In xy-line plots, specifying the derivative gives you control over
|
|
267
|
+
the initial and final slopes of the curve.
|
|
268
|
+
`CurveType.ParaSpline` (parametric spline)
|
|
269
|
+
Creates a smooth curve as with a spline, except the assumption is
|
|
270
|
+
that both variables are functions of the index of the data points.
|
|
271
|
+
For example in xy-line plot, `ParaSpline` fits :math:`x = f(i)` and
|
|
272
|
+
:math:`y=g(i)` where :math:`f()` and :math:`g()` are both smooth.
|
|
273
|
+
No additional sorting of the points is performed. This spline may
|
|
274
|
+
result in a multi-valued function of either or both axis variables.
|
|
275
|
+
|
|
276
|
+
Example usage::
|
|
277
|
+
|
|
278
|
+
>>> from tecplot.constant import CurveType
|
|
279
|
+
>>> plot.linemap(0).curve.curve_type = CurveType.PolynomialFit
|
|
280
|
+
"""
|
|
281
|
+
return self._get_style(CurveType, sv.CURVETYPE)
|
|
282
|
+
|
|
283
|
+
@curve_type.setter
|
|
284
|
+
def curve_type(self, value):
|
|
285
|
+
self._set_style(CurveType(value), sv.CURVETYPE)
|
|
286
|
+
|
|
287
|
+
@property
|
|
288
|
+
def polynomial_order(self):
|
|
289
|
+
"""`int` (1 to 10): Order of the fit when set to polynomial.
|
|
290
|
+
|
|
291
|
+
A value of 1 will fit the data to a straight line. Example usage::
|
|
292
|
+
|
|
293
|
+
>>> from tecplot.constant import CurveType
|
|
294
|
+
>>> curve = plot.linemap(0).curve
|
|
295
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
296
|
+
>>> curve.polynomial_order = 4
|
|
297
|
+
"""
|
|
298
|
+
return self._get_style(int, sv.POLYORDER)
|
|
299
|
+
|
|
300
|
+
@polynomial_order.setter
|
|
301
|
+
def polynomial_order(self, value):
|
|
302
|
+
self._set_style(int(value), sv.POLYORDER)
|
|
303
|
+
|
|
304
|
+
@property
|
|
305
|
+
def num_points(self):
|
|
306
|
+
"""`int`: Number of points to use when drawing a fitted curve.
|
|
307
|
+
|
|
308
|
+
Example usage::
|
|
309
|
+
|
|
310
|
+
>>> from tecplot.constant import CurveType
|
|
311
|
+
>>> curve = plot.linemap(0).curve
|
|
312
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
313
|
+
>>> curve.num_points = 100
|
|
314
|
+
"""
|
|
315
|
+
return self._get_style(int, sv.NUMPTS)
|
|
316
|
+
|
|
317
|
+
@num_points.setter
|
|
318
|
+
def num_points(self, value):
|
|
319
|
+
self._set_style(int(value), sv.NUMPTS)
|
|
320
|
+
|
|
321
|
+
@property
|
|
322
|
+
def use_weight_variable(self):
|
|
323
|
+
"""`bool`: Use the specified variable for curve-fit weighting.
|
|
324
|
+
|
|
325
|
+
Example usage::
|
|
326
|
+
|
|
327
|
+
>>> from tecplot.constant import CurveType
|
|
328
|
+
>>> curve = plot.linemap(0).curve
|
|
329
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
330
|
+
>>> curve.use_weight_variable = True
|
|
331
|
+
>>> curve.weight_variable_index = 3
|
|
332
|
+
"""
|
|
333
|
+
return self._get_style(bool, sv.USEWEIGHTVAR)
|
|
334
|
+
|
|
335
|
+
@use_weight_variable.setter
|
|
336
|
+
def use_weight_variable(self, value):
|
|
337
|
+
self._set_style(bool(value), sv.USEWEIGHTVAR)
|
|
338
|
+
|
|
339
|
+
@property
|
|
340
|
+
def weight_variable_index(self):
|
|
341
|
+
"""`int`: Zero-based index of the variable to use for curve-fit weighting.
|
|
342
|
+
|
|
343
|
+
The ``use_weight_variable`` attribute must be set to `True`::
|
|
344
|
+
|
|
345
|
+
>>> from tecplot.constant import CurveType
|
|
346
|
+
>>> curve = plot.linemap(0).curve
|
|
347
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
348
|
+
>>> curve.use_weight_variable = True
|
|
349
|
+
>>> curve.weight_variable_index = 3
|
|
350
|
+
"""
|
|
351
|
+
return self._get_style(tecutil.Index, sv.WEIGHTVAR)
|
|
352
|
+
|
|
353
|
+
@weight_variable_index.setter
|
|
354
|
+
def weight_variable_index(self, index):
|
|
355
|
+
self._set_style(tecutil.Index(index), sv.WEIGHTVAR)
|
|
356
|
+
|
|
357
|
+
@property
|
|
358
|
+
def weight_variable(self):
|
|
359
|
+
"""`Variable`: Variable to use for curve-fit weighting.
|
|
360
|
+
|
|
361
|
+
Example usage::
|
|
362
|
+
|
|
363
|
+
>>> from tecplot.constant import CurveType
|
|
364
|
+
>>> curve = plot.linemap(0).curve
|
|
365
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
366
|
+
>>> curve.use_weight_variable = True
|
|
367
|
+
>>> curve.weight_variable = dataset.variable('P')
|
|
368
|
+
"""
|
|
369
|
+
idx = self.weight_variable_index
|
|
370
|
+
return self.linemap.plot.frame.dataset.variable(idx)
|
|
371
|
+
|
|
372
|
+
@weight_variable.setter
|
|
373
|
+
def weight_variable(self, variable):
|
|
374
|
+
self.weight_variable_index = variable.index
|
|
375
|
+
|
|
376
|
+
@property
|
|
377
|
+
def use_fit_range(self):
|
|
378
|
+
"""`bool`: Limit the fit to the ``fit_range`` specified.
|
|
379
|
+
|
|
380
|
+
Example usage::
|
|
381
|
+
|
|
382
|
+
>>> from tecplot.constant import CurveType
|
|
383
|
+
>>> curve = plot.linemap(0).curve
|
|
384
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
385
|
+
>>> curve.use_fit_range = True
|
|
386
|
+
>>> curve.fit_range = 5, 10
|
|
387
|
+
"""
|
|
388
|
+
return self._get_style(bool, sv.USEINDVARRANGE)
|
|
389
|
+
|
|
390
|
+
@use_fit_range.setter
|
|
391
|
+
def use_fit_range(self, value):
|
|
392
|
+
self._set_style(bool(value), sv.USEINDVARRANGE)
|
|
393
|
+
|
|
394
|
+
@property
|
|
395
|
+
def fit_range(self):
|
|
396
|
+
"""`tuple`: The range to fit and display a fitted curve.
|
|
397
|
+
|
|
398
|
+
Example showing how to set the limits of a polynomial fit to [5,10].
|
|
399
|
+
The ``use_fit_range`` attribute must be set to `True`::
|
|
400
|
+
|
|
401
|
+
>>> from tecplot.constant import CurveType
|
|
402
|
+
>>> curve = plot.linemap(0).curve
|
|
403
|
+
>>> curve.curve_type = CurveType.PolynomialFit
|
|
404
|
+
>>> curve.use_fit_range = True
|
|
405
|
+
>>> curve.fit_range = 5, 10
|
|
406
|
+
"""
|
|
407
|
+
return session.IndependentVariableLimits(self)
|
|
408
|
+
|
|
409
|
+
@fit_range.setter
|
|
410
|
+
def fit_range(self, *limits):
|
|
411
|
+
limits = tecutil.flatten_args(*limits)
|
|
412
|
+
session.IndependentVariableLimits(self)[:] = limits
|
|
413
|
+
|
|
414
|
+
@property
|
|
415
|
+
def clamp_spline(self):
|
|
416
|
+
"""`bool`: Enable derivative clamping for spline fits.
|
|
417
|
+
|
|
418
|
+
Example showing how to set the derivative at the limits of a spline
|
|
419
|
+
curve to zero::
|
|
420
|
+
|
|
421
|
+
>>> from tecplot.constant import CurveType
|
|
422
|
+
>>> curve = plot.linemap(0).curve
|
|
423
|
+
>>> curve.curve_type = CurveType.Spline
|
|
424
|
+
>>> curve.clamp_spline = True
|
|
425
|
+
>>> curve.spline_derivative_at_ends = 0, 0
|
|
426
|
+
"""
|
|
427
|
+
return self._get_style(bool, sv.CLAMPSPLINE)
|
|
428
|
+
|
|
429
|
+
@clamp_spline.setter
|
|
430
|
+
def clamp_spline(self, value):
|
|
431
|
+
self._set_style(bool(value), sv.CLAMPSPLINE)
|
|
432
|
+
|
|
433
|
+
@property
|
|
434
|
+
def spline_derivative_at_ends(self):
|
|
435
|
+
"""`tuple`: Clamp the derivative of the spline fit at the edges of the range.
|
|
436
|
+
|
|
437
|
+
Example showing how to set the derivative at the limits of a spline
|
|
438
|
+
curve to zero. Notice the ``clamp_spline`` attribute must be set to
|
|
439
|
+
`True`::
|
|
440
|
+
|
|
441
|
+
>>> from tecplot.constant import CurveType
|
|
442
|
+
>>> curve = plot.linemap(0).curve
|
|
443
|
+
>>> curve.curve_type = CurveType.Spline
|
|
444
|
+
>>> curve.clamp_spline = True
|
|
445
|
+
>>> curve.spline_derivative_at_ends = 0, 0
|
|
446
|
+
"""
|
|
447
|
+
return session.SplineDerivativeAtEnds(self)
|
|
448
|
+
|
|
449
|
+
@spline_derivative_at_ends.setter
|
|
450
|
+
def spline_derivative_at_ends(self, *values):
|
|
451
|
+
values = tecutil.flatten_args(*values)
|
|
452
|
+
session.SplineDerivativeAtEnds(self)[:] = values
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
class LinemapErrorBars(session.SubStyle):
|
|
456
|
+
"""Error bar style and variable assignment control.
|
|
457
|
+
|
|
458
|
+
A single `XYLinemap` holds a single `Variable` assignment for error bars.
|
|
459
|
+
Therefore, if you wish to have separate error bars for *x* and *y*, two
|
|
460
|
+
linemaps are required:
|
|
461
|
+
|
|
462
|
+
.. code-block:: python
|
|
463
|
+
:emphasize-lines: 32-42,45
|
|
464
|
+
|
|
465
|
+
from math import sqrt
|
|
466
|
+
from os import path
|
|
467
|
+
import tecplot as tp
|
|
468
|
+
from tecplot.constant import PlotType, Color, ErrorBar
|
|
469
|
+
|
|
470
|
+
# setup dataset
|
|
471
|
+
frame = tp.active_frame()
|
|
472
|
+
ds = frame.create_dataset('Dataset')
|
|
473
|
+
for v in ['x', 'y', 'xerr', 'yerr']:
|
|
474
|
+
ds.add_variable(v)
|
|
475
|
+
zone = ds.add_ordered_zone('Zone', 5)
|
|
476
|
+
|
|
477
|
+
# create some data (x, y)
|
|
478
|
+
zone.values('x')[:] = [0,1,2,3,4]
|
|
479
|
+
zone.values('y')[:] = [1,2,4,8,10]
|
|
480
|
+
|
|
481
|
+
# error in x is a constant
|
|
482
|
+
zone.values('xerr')[:] = [0.2]*5
|
|
483
|
+
|
|
484
|
+
# error in y is the square-root of the value
|
|
485
|
+
zone.values('yerr')[:] = [sqrt(y) for y in zone.values('y')[:]]
|
|
486
|
+
|
|
487
|
+
frame.plot_type = PlotType.XYLine
|
|
488
|
+
plot = frame.plot()
|
|
489
|
+
|
|
490
|
+
plot.delete_linemaps()
|
|
491
|
+
xerr_lmap = plot.add_linemap('xerr', zone, ds.variable('x'),
|
|
492
|
+
ds.variable('y'))
|
|
493
|
+
yerr_lmap = plot.add_linemap('yerr', zone, ds.variable('x'),
|
|
494
|
+
ds.variable('y'))
|
|
495
|
+
|
|
496
|
+
xerr_lmap.error_bars.variable = ds.variable('xerr')
|
|
497
|
+
xerr_lmap.error_bars.bar_type = ErrorBar.Horz
|
|
498
|
+
xerr_lmap.error_bars.color = Color.Blue
|
|
499
|
+
xerr_lmap.error_bars.line_thickness = 0.8
|
|
500
|
+
xerr_lmap.error_bars.show = True
|
|
501
|
+
|
|
502
|
+
yerr_lmap.error_bars.variable = ds.variable('yerr')
|
|
503
|
+
yerr_lmap.error_bars.bar_type = ErrorBar.Vert
|
|
504
|
+
yerr_lmap.error_bars.color = Color.Blue
|
|
505
|
+
yerr_lmap.error_bars.line_thickness = 0.8
|
|
506
|
+
yerr_lmap.error_bars.show = True
|
|
507
|
+
|
|
508
|
+
plot.show_lines = False
|
|
509
|
+
plot.show_error_bars = True
|
|
510
|
+
|
|
511
|
+
plot.view.fit()
|
|
512
|
+
|
|
513
|
+
tp.export.save_png('linemap_error_bars.png', 600, supersample=3)
|
|
514
|
+
|
|
515
|
+
.. figure:: /_static/images/linemap_error_bars.png
|
|
516
|
+
:width: 300px
|
|
517
|
+
:figwidth: 300px
|
|
518
|
+
"""
|
|
519
|
+
def __init__(self, linemap):
|
|
520
|
+
self.linemap = linemap
|
|
521
|
+
super().__init__(linemap, sv.ERRORBARS)
|
|
522
|
+
|
|
523
|
+
@property
|
|
524
|
+
def show(self):
|
|
525
|
+
"""`bool`: Display error bars on the plot for this :ref:`Linemap`.
|
|
526
|
+
|
|
527
|
+
The parent plot object must have error bars enables as well which will
|
|
528
|
+
require a variable to be set::
|
|
529
|
+
|
|
530
|
+
>>> plot.linemap(0).error_bars.variable = dataset.variable('E')
|
|
531
|
+
>>> plot.show_error_bars = True
|
|
532
|
+
>>> plot.linemap(0).error_bars.show = True
|
|
533
|
+
"""
|
|
534
|
+
return self._get_style(bool, sv.SHOW)
|
|
535
|
+
|
|
536
|
+
@show.setter
|
|
537
|
+
def show(self, value):
|
|
538
|
+
self._set_style(bool(value), sv.SHOW)
|
|
539
|
+
|
|
540
|
+
@property
|
|
541
|
+
def bar_type(self):
|
|
542
|
+
"""`ErrorBar`: Style of the error bar to draw.
|
|
543
|
+
|
|
544
|
+
Possible values: `Up`, `Down`, `Left <ErrorBar.Left>`, `Right
|
|
545
|
+
<ErrorBar.Right>`, `Horz`, `Vert`, `Cross`.
|
|
546
|
+
|
|
547
|
+
Example usage::
|
|
548
|
+
|
|
549
|
+
>>> from tecplot.constant import ErrorBar
|
|
550
|
+
>>> plot.linemap(0).error_bars.bar_type = ErrorBar.Cross
|
|
551
|
+
"""
|
|
552
|
+
return self._get_style(ErrorBar, sv.BARTYPE)
|
|
553
|
+
|
|
554
|
+
@bar_type.setter
|
|
555
|
+
def bar_type(self, value):
|
|
556
|
+
self._set_style(ErrorBar(value), sv.BARTYPE)
|
|
557
|
+
|
|
558
|
+
@property
|
|
559
|
+
def color(self):
|
|
560
|
+
"""`Color`: `Color` of the error bars.
|
|
561
|
+
|
|
562
|
+
Example usage::
|
|
563
|
+
|
|
564
|
+
>>> from tecplot.constant import Color
|
|
565
|
+
>>> plot.linemap(0).error_bars.color = Color.Red
|
|
566
|
+
"""
|
|
567
|
+
return self._get_style(Color, sv.COLOR)
|
|
568
|
+
|
|
569
|
+
@color.setter
|
|
570
|
+
def color(self, value):
|
|
571
|
+
self._set_style(Color(value), sv.COLOR)
|
|
572
|
+
|
|
573
|
+
@property
|
|
574
|
+
def endcap_size(self):
|
|
575
|
+
"""`float`: Length of the endcaps of the error bars.
|
|
576
|
+
|
|
577
|
+
Example usage::
|
|
578
|
+
|
|
579
|
+
>>> plot.linemap(0).error_bars.endcap_size = 2.5
|
|
580
|
+
"""
|
|
581
|
+
return self._get_style(float, sv.SIZE)
|
|
582
|
+
|
|
583
|
+
@endcap_size.setter
|
|
584
|
+
def endcap_size(self, value):
|
|
585
|
+
self._set_style(float(value), sv.SIZE)
|
|
586
|
+
|
|
587
|
+
@property
|
|
588
|
+
def line_thickness(self):
|
|
589
|
+
"""`float`: Width of the error bar lines.
|
|
590
|
+
|
|
591
|
+
Example usage::
|
|
592
|
+
|
|
593
|
+
>>> plot.linemap(0).error_bars.line_thickness = 0.8
|
|
594
|
+
"""
|
|
595
|
+
return self._get_style(float, sv.LINETHICKNESS)
|
|
596
|
+
|
|
597
|
+
@line_thickness.setter
|
|
598
|
+
def line_thickness(self, value):
|
|
599
|
+
self._set_style(float(value), sv.LINETHICKNESS)
|
|
600
|
+
|
|
601
|
+
@property
|
|
602
|
+
def step_mode(self):
|
|
603
|
+
"""`StepMode`: Space the error bars by index or frame height.
|
|
604
|
+
|
|
605
|
+
This example will make sure all error bars are no closer than 10% of the
|
|
606
|
+
frame height to each other::
|
|
607
|
+
|
|
608
|
+
>>> from tecplot.constant import StepMode
|
|
609
|
+
>>> ebars = plot.linemap(0).error_bars
|
|
610
|
+
>>> ebars.step_mode = StepMode.ByFrameUnits
|
|
611
|
+
>>> ebars.step = 10
|
|
612
|
+
"""
|
|
613
|
+
return self._get_style(StepMode, sv.SKIPMODE)
|
|
614
|
+
|
|
615
|
+
@step_mode.setter
|
|
616
|
+
def step_mode(self, value):
|
|
617
|
+
self._set_style(StepMode(value), sv.SKIPMODE)
|
|
618
|
+
|
|
619
|
+
@property
|
|
620
|
+
def step(self):
|
|
621
|
+
"""`float`: Space between points to show error bars.
|
|
622
|
+
|
|
623
|
+
The step is specified either as a percentage of the frame height or
|
|
624
|
+
as a number of indices to skip depending on the value of
|
|
625
|
+
`LinemapErrorBars.step_mode`. This example will add error
|
|
626
|
+
bars to every third point::
|
|
627
|
+
|
|
628
|
+
>>> plot.linemap(0).error_bars.step = 3
|
|
629
|
+
"""
|
|
630
|
+
return self._get_style(float, sv.SKIPPING)
|
|
631
|
+
|
|
632
|
+
@step.setter
|
|
633
|
+
def step(self, value):
|
|
634
|
+
if __debug__:
|
|
635
|
+
if value < 0:
|
|
636
|
+
raise TecplotLogicError('step must be >= 0')
|
|
637
|
+
self._set_style(float(value), sv.SKIPPING)
|
|
638
|
+
|
|
639
|
+
@property
|
|
640
|
+
def variable_index(self):
|
|
641
|
+
"""`int`: Zero-based variable index to use for error bar sizes.
|
|
642
|
+
|
|
643
|
+
Example usage::
|
|
644
|
+
|
|
645
|
+
>>> plot.linemap(0).error_bars.variable_index = 3
|
|
646
|
+
"""
|
|
647
|
+
return self._get_style(tecutil.Index, sv.VAR)
|
|
648
|
+
|
|
649
|
+
@variable_index.setter
|
|
650
|
+
def variable_index(self, index):
|
|
651
|
+
self._set_style(tecutil.Index(index), sv.VAR)
|
|
652
|
+
|
|
653
|
+
@property
|
|
654
|
+
def variable(self):
|
|
655
|
+
"""`Variable`: `Variable` to use for error bar sizes.
|
|
656
|
+
|
|
657
|
+
Example usage::
|
|
658
|
+
|
|
659
|
+
>>> ebars = plot.linemap(0).error_bars
|
|
660
|
+
>>> ebars.variable = dataset.variable('Err')
|
|
661
|
+
"""
|
|
662
|
+
return self.linemap.plot.frame.dataset.variable(self.variable_index)
|
|
663
|
+
|
|
664
|
+
@variable.setter
|
|
665
|
+
def variable(self, variable):
|
|
666
|
+
self.variable_index = variable.index
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
class LinemapIndices(session.SubStyle):
|
|
670
|
+
"""Ordering and spacing of points to be drawn.
|
|
671
|
+
|
|
672
|
+
Each mapping can show either *I*, *J*, or *K*-varying families of lines. By
|
|
673
|
+
default, the *I*-varying family of lines are displayed. You can also choose
|
|
674
|
+
which members of the family are drawn (and using which data points), by
|
|
675
|
+
specifying index ranges for each of *I*, *J*, and *K*. The index range for
|
|
676
|
+
the varying index says which points to include in each line, and the index
|
|
677
|
+
ranges for the other indices determine which lines in the family to
|
|
678
|
+
include:
|
|
679
|
+
|
|
680
|
+
.. code-block:: python
|
|
681
|
+
:emphasize-lines: 15-16
|
|
682
|
+
|
|
683
|
+
from os import path
|
|
684
|
+
import tecplot as tp
|
|
685
|
+
from tecplot.constant import PlotType, IJKLines
|
|
686
|
+
|
|
687
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
688
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
689
|
+
dataset = tp.data.load_tecplot(infile)
|
|
690
|
+
|
|
691
|
+
frame = tp.active_frame()
|
|
692
|
+
frame.plot_type = PlotType.XYLine
|
|
693
|
+
plot = frame.plot()
|
|
694
|
+
|
|
695
|
+
lmaps = plot.linemaps(0, 1, 2)
|
|
696
|
+
lmaps.show = True
|
|
697
|
+
lmaps.indices.varying_index = IJKLines.I
|
|
698
|
+
lmaps.indices.i_range = 0,0,3
|
|
699
|
+
|
|
700
|
+
# save image to file
|
|
701
|
+
tp.export.save_png('linemap_indices.png', 600, supersample=3)
|
|
702
|
+
|
|
703
|
+
.. figure:: /_static/images/linemap_indices.png
|
|
704
|
+
:width: 300px
|
|
705
|
+
:figwidth: 300px
|
|
706
|
+
"""
|
|
707
|
+
def __init__(self, linemap):
|
|
708
|
+
self.linemap = linemap
|
|
709
|
+
super().__init__(linemap, sv.INDICES)
|
|
710
|
+
|
|
711
|
+
@property
|
|
712
|
+
def varying_index(self):
|
|
713
|
+
"""`IJKLines`: Family of lines to be drawn.
|
|
714
|
+
|
|
715
|
+
This is the order which varies along the lines drawn. *K*-varying is
|
|
716
|
+
only available if the mapping is using an *IJK*-ordered zone::
|
|
717
|
+
|
|
718
|
+
>>> from tecplot.constant import IJKLines
|
|
719
|
+
>>> plot.linemap(0).indices.varying_index = IJKLines.J
|
|
720
|
+
"""
|
|
721
|
+
return self._get_style(IJKLines, sv.IJKLINES)
|
|
722
|
+
|
|
723
|
+
@varying_index.setter
|
|
724
|
+
def varying_index(self, index):
|
|
725
|
+
self._set_style(IJKLines(index), sv.IJKLINES)
|
|
726
|
+
|
|
727
|
+
@property
|
|
728
|
+
def i_range(self):
|
|
729
|
+
"""`tuple` of `integers <int>` (min, max, step): `IndexRange` for the *I* dimension of ordered data.
|
|
730
|
+
|
|
731
|
+
This example shows ``I``-lines at ``i = [0, 2, 4, 6, 8, 10]``::
|
|
732
|
+
|
|
733
|
+
>>> plot.linemap(0).indices.i_range = 0, 10, 2
|
|
734
|
+
"""
|
|
735
|
+
return session.IndexRange(self, sv.IRANGE)
|
|
736
|
+
|
|
737
|
+
@i_range.setter
|
|
738
|
+
def i_range(self, values):
|
|
739
|
+
session.IndexRange(self, sv.IRANGE)[:] = values
|
|
740
|
+
|
|
741
|
+
@property
|
|
742
|
+
def j_range(self):
|
|
743
|
+
"""`tuple` of `integers <int>` (min, max, step): `IndexRange` for the *J* dimension of ordered data.
|
|
744
|
+
|
|
745
|
+
This example shows all ``J``-lines starting with ``j = 10`` up to the
|
|
746
|
+
maximum ``J``-line of the associated `Zone <data_access>`::
|
|
747
|
+
|
|
748
|
+
>>> plot.linemap(0).indices.j_range = 10, None, 1
|
|
749
|
+
"""
|
|
750
|
+
return session.IndexRange(self, sv.JRANGE)
|
|
751
|
+
|
|
752
|
+
@j_range.setter
|
|
753
|
+
def j_range(self, values):
|
|
754
|
+
session.IndexRange(self, sv.JRANGE)[:] = values
|
|
755
|
+
|
|
756
|
+
@property
|
|
757
|
+
def k_range(self):
|
|
758
|
+
"""`tuple` of `integers <int>` (min, max, step): `IndexRange` for the *K* dimension of ordered data.
|
|
759
|
+
|
|
760
|
+
This example shows all ``K``-lines starting with the first up to 5
|
|
761
|
+
from the last ``K``-line of the associated `Zone <data_access>`::
|
|
762
|
+
|
|
763
|
+
>>> plot.linemap(0).indices.k_range = None, -5
|
|
764
|
+
"""
|
|
765
|
+
return session.IndexRange(self, sv.KRANGE)
|
|
766
|
+
|
|
767
|
+
@k_range.setter
|
|
768
|
+
def k_range(self, values):
|
|
769
|
+
session.IndexRange(self, sv.KRANGE)[:] = values
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
class LinemapLine(session.SubStyle):
|
|
773
|
+
"""Style control for the line to be drawn.
|
|
774
|
+
|
|
775
|
+
This controls the style of the lines plotted for a given `XYLinemap`:
|
|
776
|
+
|
|
777
|
+
.. code-block:: python
|
|
778
|
+
:emphasize-lines: 15-19
|
|
779
|
+
|
|
780
|
+
from os import path
|
|
781
|
+
import tecplot as tp
|
|
782
|
+
from tecplot.constant import PlotType, Color, LinePattern
|
|
783
|
+
|
|
784
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
785
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
786
|
+
dataset = tp.data.load_tecplot(infile)
|
|
787
|
+
|
|
788
|
+
frame = tp.active_frame()
|
|
789
|
+
frame.plot_type = PlotType.XYLine
|
|
790
|
+
plot = frame.plot()
|
|
791
|
+
|
|
792
|
+
lmap = plot.linemap(0)
|
|
793
|
+
|
|
794
|
+
line = lmap.line
|
|
795
|
+
line.color = Color.Blue
|
|
796
|
+
line.line_thickness = 1
|
|
797
|
+
line.line_pattern = LinePattern.LongDash
|
|
798
|
+
line.pattern_length = 2
|
|
799
|
+
|
|
800
|
+
tp.export.save_png('linemap_line.png', 600, supersample=3)
|
|
801
|
+
|
|
802
|
+
.. figure:: /_static/images/linemap_line.png
|
|
803
|
+
:width: 300px
|
|
804
|
+
:figwidth: 300px
|
|
805
|
+
"""
|
|
806
|
+
def __init__(self, linemap):
|
|
807
|
+
self.linemap = linemap
|
|
808
|
+
super().__init__(linemap, sv.LINES)
|
|
809
|
+
|
|
810
|
+
@property
|
|
811
|
+
def show(self):
|
|
812
|
+
"""`bool`: Display this point-to-point line on the plot.
|
|
813
|
+
|
|
814
|
+
Example usage::
|
|
815
|
+
|
|
816
|
+
>>> plot.linemap(0).line.show = True
|
|
817
|
+
"""
|
|
818
|
+
return self._get_style(bool, sv.SHOW)
|
|
819
|
+
|
|
820
|
+
@show.setter
|
|
821
|
+
def show(self, value):
|
|
822
|
+
self._set_style(bool(value), sv.SHOW)
|
|
823
|
+
|
|
824
|
+
@property
|
|
825
|
+
def color(self):
|
|
826
|
+
"""`Color`: `Color` of the line to be drawn.
|
|
827
|
+
|
|
828
|
+
Example usage::
|
|
829
|
+
|
|
830
|
+
>>> from tecplot.constant import Color
|
|
831
|
+
>>> plot.linemap(0).line.color = Color.Blue
|
|
832
|
+
"""
|
|
833
|
+
return self._get_style(Color, sv.COLOR)
|
|
834
|
+
|
|
835
|
+
@color.setter
|
|
836
|
+
def color(self, value):
|
|
837
|
+
self._set_style(Color(value), sv.COLOR)
|
|
838
|
+
|
|
839
|
+
@property
|
|
840
|
+
def line_thickness(self):
|
|
841
|
+
"""`float`: Width of the line to be drawn.
|
|
842
|
+
|
|
843
|
+
Example usage::
|
|
844
|
+
|
|
845
|
+
>>> plot.linemap(0).line.line_thickness = 0.5
|
|
846
|
+
"""
|
|
847
|
+
return self._get_style(float, sv.LINETHICKNESS)
|
|
848
|
+
|
|
849
|
+
@line_thickness.setter
|
|
850
|
+
def line_thickness(self, value):
|
|
851
|
+
self._set_style(float(value), sv.LINETHICKNESS)
|
|
852
|
+
|
|
853
|
+
@property
|
|
854
|
+
def line_pattern(self):
|
|
855
|
+
"""`LinePattern`: Pattern style of the line to be drawn.
|
|
856
|
+
|
|
857
|
+
Possible values: `Solid <LinePattern.Solid>`, `Dashed`, `DashDot`,
|
|
858
|
+
`Dotted`, `LongDash`, `DashDotDot`.
|
|
859
|
+
|
|
860
|
+
Example usage::
|
|
861
|
+
|
|
862
|
+
>>> from tecplot.constant import LinePattern
|
|
863
|
+
>>> lmap = plot.linemap(0)
|
|
864
|
+
>>> lmap.line.line_pattern = LinePattern.LongDash
|
|
865
|
+
"""
|
|
866
|
+
return self._get_style(LinePattern, sv.LINEPATTERN)
|
|
867
|
+
|
|
868
|
+
@line_pattern.setter
|
|
869
|
+
def line_pattern(self, value):
|
|
870
|
+
self._set_style(LinePattern(value), sv.LINEPATTERN)
|
|
871
|
+
|
|
872
|
+
@property
|
|
873
|
+
def pattern_length(self):
|
|
874
|
+
"""`float`: Segment length of the repeated line pattern.
|
|
875
|
+
|
|
876
|
+
Example usage::
|
|
877
|
+
|
|
878
|
+
>>> from tecplot.constant import LinePattern
|
|
879
|
+
>>> lmap = plot.linemap(0)
|
|
880
|
+
>>> lmap.line.line_pattern = LinePattern.LongDash
|
|
881
|
+
>>> lmap.line.pattern_length = 3.5
|
|
882
|
+
"""
|
|
883
|
+
return self._get_style(float, sv.PATTERNLENGTH)
|
|
884
|
+
|
|
885
|
+
@pattern_length.setter
|
|
886
|
+
def pattern_length(self, value):
|
|
887
|
+
self._set_style(float(value), sv.PATTERNLENGTH)
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
class LinemapSymbols(session.SubStyle):
|
|
891
|
+
"""Style control for markers placed along lines.
|
|
892
|
+
|
|
893
|
+
This class allows the user to set the style of the symbols to be shown
|
|
894
|
+
including setting a geometric shape, text character, line and fill
|
|
895
|
+
colors and spacing. The plot-level ``show_symbols`` attribute must be
|
|
896
|
+
enabled to show symbols in any specific linemap within the plot:
|
|
897
|
+
|
|
898
|
+
.. code-block:: python
|
|
899
|
+
:emphasize-lines: 12,16-22
|
|
900
|
+
|
|
901
|
+
from os import path
|
|
902
|
+
import tecplot as tp
|
|
903
|
+
from tecplot.constant import PlotType, Color, FillMode, GeomShape
|
|
904
|
+
|
|
905
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
906
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
907
|
+
dataset = tp.data.load_tecplot(infile)
|
|
908
|
+
|
|
909
|
+
frame = tp.active_frame()
|
|
910
|
+
frame.plot_type = PlotType.XYLine
|
|
911
|
+
plot = frame.plot()
|
|
912
|
+
plot.show_symbols = True
|
|
913
|
+
|
|
914
|
+
lmaps = plot.linemaps(0, 1, 2)
|
|
915
|
+
|
|
916
|
+
lmaps.symbols.show = True
|
|
917
|
+
lmaps.symbols.symbol().shape = GeomShape.Square
|
|
918
|
+
lmaps.symbols.size = 2.5
|
|
919
|
+
lmaps.symbols.color = Color.Blue
|
|
920
|
+
lmaps.symbols.line_thickness = 0.4
|
|
921
|
+
lmaps.symbols.fill_mode = FillMode.UseSpecificColor
|
|
922
|
+
lmaps.symbols.fill_color = Color.Azure
|
|
923
|
+
|
|
924
|
+
# save image to file
|
|
925
|
+
tp.export.save_png('linemap_symbols.png', 600, supersample=3)
|
|
926
|
+
|
|
927
|
+
.. figure:: /_static/images/linemap_symbols.png
|
|
928
|
+
:width: 300px
|
|
929
|
+
:figwidth: 300px
|
|
930
|
+
"""
|
|
931
|
+
def __init__(self, linemap):
|
|
932
|
+
self.linemap = linemap
|
|
933
|
+
super().__init__(linemap, sv.SYMBOLS)
|
|
934
|
+
|
|
935
|
+
@property
|
|
936
|
+
def show(self):
|
|
937
|
+
"""`bool`: Display symbols along the lines to be drawn.
|
|
938
|
+
|
|
939
|
+
The parent plot object must have symbols enabled as well::
|
|
940
|
+
|
|
941
|
+
>>> plot.show_symbols = True
|
|
942
|
+
>>> plot.linemap(0).symbols.show = True
|
|
943
|
+
"""
|
|
944
|
+
return self._get_style(bool, sv.SHOW)
|
|
945
|
+
|
|
946
|
+
@show.setter
|
|
947
|
+
def show(self, value):
|
|
948
|
+
self._set_style(bool(value), sv.SHOW)
|
|
949
|
+
|
|
950
|
+
@property
|
|
951
|
+
def symbol_type(self):
|
|
952
|
+
"""`SymbolType`: The `SymbolType` to use for this linemap.
|
|
953
|
+
|
|
954
|
+
Possible values are: `SymbolType.Geometry`, `SymbolType.Text`.
|
|
955
|
+
|
|
956
|
+
This sets the active symbol type. Use LinemapSymbols.symbol` to access
|
|
957
|
+
the symbol::
|
|
958
|
+
|
|
959
|
+
>>> from tecplot.constant import SymbolType
|
|
960
|
+
>>> linemap = plot.linemap(0)
|
|
961
|
+
>>> linemap.symbols.symbol_type = SymbolType.Text
|
|
962
|
+
>>> symbol = linemap.symbols.symbol(SymbolType.Text)
|
|
963
|
+
>>> symbol.text = 'a'
|
|
964
|
+
"""
|
|
965
|
+
return symbol.Symbol(self)._symbol_type
|
|
966
|
+
|
|
967
|
+
@symbol_type.setter
|
|
968
|
+
def symbol_type(self, value):
|
|
969
|
+
symbol.Symbol(self)._symbol_type = value
|
|
970
|
+
|
|
971
|
+
def symbol(self, symbol_type=None):
|
|
972
|
+
"""Returns a linemap symbol style object.
|
|
973
|
+
|
|
974
|
+
Parameters:
|
|
975
|
+
symbol_type (`SymbolType`, optional): The type of symbol to return.
|
|
976
|
+
By default, this will return the active symbol type which is
|
|
977
|
+
obtained from `LinemapSymbols.symbol_type`.
|
|
978
|
+
|
|
979
|
+
Returns: `TextSymbol` or `GeometrySymbol`
|
|
980
|
+
|
|
981
|
+
Example usage::
|
|
982
|
+
|
|
983
|
+
>>> from tecplot.constant import SymbolType
|
|
984
|
+
>>> plot.linemap(0).symbols.symbol_type = SymbolType.Text
|
|
985
|
+
>>> symbol = plot.linemap(0).symbols.symbol()
|
|
986
|
+
>>> symbol.text = 'a'
|
|
987
|
+
"""
|
|
988
|
+
_dispatch = {
|
|
989
|
+
SymbolType.Text: symbol.TextSymbol,
|
|
990
|
+
SymbolType.Geometry: symbol.GeometrySymbol}
|
|
991
|
+
if symbol_type is None:
|
|
992
|
+
symbol_type = self.symbol_type
|
|
993
|
+
if isinstance(symbol_type, Iterable):
|
|
994
|
+
if not all(t is symbol_type[0] for t in symbol_type):
|
|
995
|
+
msg = 'Linemap symbols are not all the same type'
|
|
996
|
+
raise TecplotLogicError(msg)
|
|
997
|
+
symbol_type = symbol_type[0]
|
|
998
|
+
return _dispatch[symbol_type or self.symbol_type](self)
|
|
999
|
+
|
|
1000
|
+
@property
|
|
1001
|
+
def step_mode(self):
|
|
1002
|
+
"""`StepMode`: Space the symbols by index or frame height.
|
|
1003
|
+
|
|
1004
|
+
This example will make sure all symbols are no closer than 10% of the
|
|
1005
|
+
frame height to each other::
|
|
1006
|
+
|
|
1007
|
+
>>> from tecplot.constant import StepMode
|
|
1008
|
+
>>> sym = plot.linemap(0).symbols
|
|
1009
|
+
>>> sym.step_mode = StepMode.ByFrameUnits
|
|
1010
|
+
>>> sym.step = 10
|
|
1011
|
+
"""
|
|
1012
|
+
return self._get_style(StepMode, sv.SKIPMODE)
|
|
1013
|
+
|
|
1014
|
+
@step_mode.setter
|
|
1015
|
+
def step_mode(self, value):
|
|
1016
|
+
self._set_style(StepMode(value), sv.SKIPMODE)
|
|
1017
|
+
|
|
1018
|
+
@property
|
|
1019
|
+
def step(self):
|
|
1020
|
+
"""`float`: Space between symbols to be shown.
|
|
1021
|
+
|
|
1022
|
+
The step is specified either as a percentage of the frame height or
|
|
1023
|
+
as a number of indices to skip depending on the value of
|
|
1024
|
+
`LinemapSymbols.step_mode`. This example will add symbols
|
|
1025
|
+
to every third point::
|
|
1026
|
+
|
|
1027
|
+
>>> plot.linemap(0).symbols.step = 3
|
|
1028
|
+
"""
|
|
1029
|
+
return self._get_style(float, sv.SKIPPING)
|
|
1030
|
+
|
|
1031
|
+
@step.setter
|
|
1032
|
+
def step(self, value):
|
|
1033
|
+
if __debug__:
|
|
1034
|
+
if value < 0:
|
|
1035
|
+
raise TecplotLogicError('step must be >= 0')
|
|
1036
|
+
self._set_style(float(value), sv.SKIPPING)
|
|
1037
|
+
|
|
1038
|
+
@property
|
|
1039
|
+
def size(self):
|
|
1040
|
+
"""`float`: Size of the symbols to draw.
|
|
1041
|
+
|
|
1042
|
+
Example usage::
|
|
1043
|
+
|
|
1044
|
+
>>> plot.linemap(0).symbols.size = 3.5
|
|
1045
|
+
"""
|
|
1046
|
+
return self._get_style(float, sv.SIZE)
|
|
1047
|
+
|
|
1048
|
+
@size.setter
|
|
1049
|
+
def size(self, value):
|
|
1050
|
+
self._set_style(float(value), sv.SIZE)
|
|
1051
|
+
|
|
1052
|
+
@property
|
|
1053
|
+
def fill_mode(self):
|
|
1054
|
+
"""`FillMode`: The fill mode for the background.
|
|
1055
|
+
|
|
1056
|
+
Possible values: `FillMode.UseSpecificColor`, `FillMode.UseLineColor`,
|
|
1057
|
+
`FillMode.UseBackgroundColor` or `FillMode.None_`.
|
|
1058
|
+
|
|
1059
|
+
Example usage::
|
|
1060
|
+
|
|
1061
|
+
>>> from tecplot.constant import Color, FillMode
|
|
1062
|
+
>>> symbols = plot.linemap(0).symbols
|
|
1063
|
+
>>> symbols.fill_mode = FillMode.UseBackgroundColor
|
|
1064
|
+
"""
|
|
1065
|
+
return self._get_style(FillMode, sv.FILLMODE)
|
|
1066
|
+
|
|
1067
|
+
@fill_mode.setter
|
|
1068
|
+
def fill_mode(self, value):
|
|
1069
|
+
self._set_style(FillMode(value), sv.FILLMODE)
|
|
1070
|
+
|
|
1071
|
+
@property
|
|
1072
|
+
def fill_color(self):
|
|
1073
|
+
"""`Color`: The fill or background color.
|
|
1074
|
+
|
|
1075
|
+
The ``fill_mode`` attribute must be set to
|
|
1076
|
+
`FillMode.UseSpecificColor`::
|
|
1077
|
+
|
|
1078
|
+
>>> from tecplot.constant import Color, FillMode
|
|
1079
|
+
>>> symbols = plot.linemap(0).symbols
|
|
1080
|
+
>>> symbols.fill_mode = FillMode.UseSpecificColor
|
|
1081
|
+
>>> symbols.fill_color = Color.Yellow
|
|
1082
|
+
"""
|
|
1083
|
+
return self._get_style(Color, sv.FILLCOLOR)
|
|
1084
|
+
|
|
1085
|
+
@fill_color.setter
|
|
1086
|
+
def fill_color(self, value):
|
|
1087
|
+
self._set_style(Color(value), sv.FILLCOLOR)
|
|
1088
|
+
|
|
1089
|
+
@property
|
|
1090
|
+
def color(self):
|
|
1091
|
+
"""`Color`: Edge or text `Color` of the drawn symbols.
|
|
1092
|
+
|
|
1093
|
+
Example usage::
|
|
1094
|
+
|
|
1095
|
+
>>> from tecplot.constant import Color
|
|
1096
|
+
>>> plot.linemap(1).symbols.color = Color.Blue
|
|
1097
|
+
"""
|
|
1098
|
+
return self._get_style(Color, sv.COLOR)
|
|
1099
|
+
|
|
1100
|
+
@color.setter
|
|
1101
|
+
def color(self, value):
|
|
1102
|
+
self._set_style(Color(value), sv.COLOR)
|
|
1103
|
+
|
|
1104
|
+
@property
|
|
1105
|
+
def line_thickness(self):
|
|
1106
|
+
"""`float`: Width of the lines when drawing geometry symbols.
|
|
1107
|
+
|
|
1108
|
+
Example usage::
|
|
1109
|
+
|
|
1110
|
+
>>> from tecplot.constant import SymbolType
|
|
1111
|
+
>>> symbols = plot.linemap(0).symbols
|
|
1112
|
+
>>> symbols.symbol_type = SymbolType.Geometry
|
|
1113
|
+
>>> symbols.line_thickness = 0.8
|
|
1114
|
+
"""
|
|
1115
|
+
return self._get_style(float, sv.LINETHICKNESS)
|
|
1116
|
+
|
|
1117
|
+
@line_thickness.setter
|
|
1118
|
+
def line_thickness(self, value):
|
|
1119
|
+
self._set_style(float(value), sv.LINETHICKNESS)
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
class LinemapCollection(session.Style):
|
|
1123
|
+
"""Style control for line plots.
|
|
1124
|
+
|
|
1125
|
+
The Linemap layer controls how ordered or connected data is represented.
|
|
1126
|
+
This may be either a simple collection of line segments connecting all the
|
|
1127
|
+
data points, or a curve fitted to the original data:
|
|
1128
|
+
|
|
1129
|
+
.. code-block:: python
|
|
1130
|
+
:emphasize-lines: 23-26,29-31
|
|
1131
|
+
|
|
1132
|
+
from os import path
|
|
1133
|
+
import tecplot as tp
|
|
1134
|
+
from tecplot.constant import PlotType, Color, LinePattern, AxisTitleMode
|
|
1135
|
+
|
|
1136
|
+
# load data from examples directory
|
|
1137
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
1138
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
1139
|
+
dataset = tp.data.load_tecplot(infile)
|
|
1140
|
+
|
|
1141
|
+
# get handle to the active frame and set plot type to XY Line
|
|
1142
|
+
frame = tp.active_frame()
|
|
1143
|
+
frame.plot_type = PlotType.XYLine
|
|
1144
|
+
plot = frame.plot()
|
|
1145
|
+
|
|
1146
|
+
# We will set the name, color and a few other properties
|
|
1147
|
+
# for the first three linemaps in the dataset.
|
|
1148
|
+
names = ['Seattle', 'Dallas', 'Miami']
|
|
1149
|
+
colors = [Color.Blue, Color.DeepRed, Color.Khaki]
|
|
1150
|
+
|
|
1151
|
+
lmaps = plot.linemaps()
|
|
1152
|
+
|
|
1153
|
+
# set common style for all linemaps in the collection
|
|
1154
|
+
lmaps.show = True
|
|
1155
|
+
lmaps.line.line_thickness = 1
|
|
1156
|
+
lmaps.line.line_pattern = LinePattern.LongDash
|
|
1157
|
+
lmaps.line.pattern_length = 2
|
|
1158
|
+
|
|
1159
|
+
# loop over the linemaps, setting name and color for each
|
|
1160
|
+
for lmap, name, color in zip(lmaps, names, colors):
|
|
1161
|
+
lmap.name = name
|
|
1162
|
+
lmap.line.color = color
|
|
1163
|
+
|
|
1164
|
+
# Set the y-axis label
|
|
1165
|
+
plot.axes.y_axis(0).title.title_mode = AxisTitleMode.UseText
|
|
1166
|
+
plot.axes.y_axis(0).title.text = 'Rainfall'
|
|
1167
|
+
|
|
1168
|
+
# Turn on legend
|
|
1169
|
+
plot.legend.show = True
|
|
1170
|
+
|
|
1171
|
+
# Adjust the axes limits to show all the data
|
|
1172
|
+
plot.view.fit()
|
|
1173
|
+
|
|
1174
|
+
# save image to file
|
|
1175
|
+
tp.export.save_png('linemap.png', 600, supersample=3)
|
|
1176
|
+
|
|
1177
|
+
.. figure:: /_static/images/linemap.png
|
|
1178
|
+
:width: 300px
|
|
1179
|
+
:figwidth: 300px
|
|
1180
|
+
"""
|
|
1181
|
+
def __init__(self, plot, *indices):
|
|
1182
|
+
self._indices = set(tecutil.flatten_args(*indices))
|
|
1183
|
+
self.plot = plot
|
|
1184
|
+
super().__init__(sv.LINEMAP, uniqueid=self.plot.frame.uid,
|
|
1185
|
+
objectset=self._indices)
|
|
1186
|
+
|
|
1187
|
+
@property
|
|
1188
|
+
def linemap_indices(self):
|
|
1189
|
+
"""`list`: Read-only, sorted `list` of zero-based fieldmap indices."""
|
|
1190
|
+
return sorted(self._indices)
|
|
1191
|
+
|
|
1192
|
+
@property
|
|
1193
|
+
def _uids(self):
|
|
1194
|
+
with self.plot.frame.activated():
|
|
1195
|
+
uids = [_tecutil.LineMapGetUniqueID(i + 1) for i in self.linemap_indices]
|
|
1196
|
+
return tuple(uids)
|
|
1197
|
+
|
|
1198
|
+
def __iter__(self):
|
|
1199
|
+
self._current_index = -1
|
|
1200
|
+
self._max_index = len(self._indices)
|
|
1201
|
+
return self
|
|
1202
|
+
|
|
1203
|
+
def __next__(self):
|
|
1204
|
+
self._current_index += 1
|
|
1205
|
+
if self._current_index < self._max_index:
|
|
1206
|
+
return self[self._current_index]
|
|
1207
|
+
raise StopIteration
|
|
1208
|
+
|
|
1209
|
+
def next(self): # if sys.version_info < (3,)
|
|
1210
|
+
return self.__next__()
|
|
1211
|
+
|
|
1212
|
+
def __eq__(self, that):
|
|
1213
|
+
self_uids = self._uids
|
|
1214
|
+
that_uids = that._uids
|
|
1215
|
+
return (len(self_uids) == len(that_uids)
|
|
1216
|
+
and all(a == b for a, b in zip(self_uids, that_uids)))
|
|
1217
|
+
|
|
1218
|
+
def __ne__(self, that):
|
|
1219
|
+
return not (self == that)
|
|
1220
|
+
|
|
1221
|
+
def __iadd__(self, that):
|
|
1222
|
+
if isinstance(that, type(self)):
|
|
1223
|
+
self._indices |= that._indices
|
|
1224
|
+
else:
|
|
1225
|
+
self._indices |= self.plot._linemap_indices(that)
|
|
1226
|
+
return self
|
|
1227
|
+
|
|
1228
|
+
def __isub__(self, that):
|
|
1229
|
+
if isinstance(that, type(self)):
|
|
1230
|
+
self._indices -= that._indices
|
|
1231
|
+
else:
|
|
1232
|
+
self._indices -= self.plot._linemap_indices(that)
|
|
1233
|
+
return self
|
|
1234
|
+
|
|
1235
|
+
@property
|
|
1236
|
+
def name(self):
|
|
1237
|
+
"""`str`: Name identifier of this :ref:`Linemap`.
|
|
1238
|
+
|
|
1239
|
+
Names are automatically assigned to each mapping. The nature of the
|
|
1240
|
+
name depends on the type of data used to create the mapping. If your
|
|
1241
|
+
data has only one dependent variable, the default is to use the zone
|
|
1242
|
+
name for the mapping. If your data has multiple dependent variables,
|
|
1243
|
+
then the default is to use the dependent variable name for the mapping.
|
|
1244
|
+
In either case each mapping is assigned a special name (``&ZN&`` or
|
|
1245
|
+
``&DN&``) that is replaced with the zone or variable name when the name
|
|
1246
|
+
is displayed.
|
|
1247
|
+
|
|
1248
|
+
Selecting variables in a 3D finite element zone may require significant
|
|
1249
|
+
time, since the variable must be loaded over the entire zone. XY and
|
|
1250
|
+
Polar line plots are best used with linear or ordered data, or with
|
|
1251
|
+
two-dimensional finite element data.
|
|
1252
|
+
|
|
1253
|
+
Certain placeholder text will be replaced with values based on elements
|
|
1254
|
+
within the plot. By combining static text with these placeholders, you
|
|
1255
|
+
can construct a name in any format you like::
|
|
1256
|
+
|
|
1257
|
+
>>> plot.linemap(2).name = 'Zone: &ZN&'
|
|
1258
|
+
|
|
1259
|
+
The placeholders available are:
|
|
1260
|
+
|
|
1261
|
+
Zone name (``&ZN&``)
|
|
1262
|
+
This will be replaced with the actual name of the zone assigned to
|
|
1263
|
+
that mapping.
|
|
1264
|
+
Zone number (``&Z#&``)
|
|
1265
|
+
This will be replaced with the actual number of the zone assigned
|
|
1266
|
+
to the mapping.
|
|
1267
|
+
Independent variable name (``&IV&``)
|
|
1268
|
+
This will be replaced with the actual name of the independent
|
|
1269
|
+
variable assigned to that mapping.
|
|
1270
|
+
Independent variable number (``&I#&``)
|
|
1271
|
+
This will be replaced with the actual number of the independent
|
|
1272
|
+
variable assigned to the mapping.
|
|
1273
|
+
Dependent variable name (``&DV&``)
|
|
1274
|
+
This will be replaced with the actual name of the dependent
|
|
1275
|
+
variable assigned to that mapping.
|
|
1276
|
+
Dependent variable number (``&D#&``)
|
|
1277
|
+
This will be replaced with the actual number of the dependent
|
|
1278
|
+
variable assigned to the mapping.
|
|
1279
|
+
Map number (``&M#&``)
|
|
1280
|
+
This will be replaced with the actual number of the mapping.
|
|
1281
|
+
X-Axis number (``&X#&``)
|
|
1282
|
+
This will be replaced with the actual number of the X-axis assigned
|
|
1283
|
+
to that mapping for XY Line plots. This option is not available
|
|
1284
|
+
for Polar Line plots.
|
|
1285
|
+
Y-Axis number (``&Y#&``)
|
|
1286
|
+
This will be replaced with the actual number of the Y-axis assigned
|
|
1287
|
+
to that mapping for XY Line plots. This option is not available
|
|
1288
|
+
for Polar Line plots.
|
|
1289
|
+
"""
|
|
1290
|
+
return self._get_style(str, sv.NAME)
|
|
1291
|
+
|
|
1292
|
+
@name.setter
|
|
1293
|
+
def name(self, name):
|
|
1294
|
+
self._set_style(str(name), sv.NAME)
|
|
1295
|
+
|
|
1296
|
+
@property
|
|
1297
|
+
def show(self):
|
|
1298
|
+
"""`bool`: Display this linemap on the plot.
|
|
1299
|
+
|
|
1300
|
+
Example usage for turning on all linemaps::
|
|
1301
|
+
|
|
1302
|
+
>>> plot.linemaps().show = True
|
|
1303
|
+
"""
|
|
1304
|
+
return tuple([i in self.plot.active_linemap_indices
|
|
1305
|
+
for i in self.linemap_indices])
|
|
1306
|
+
|
|
1307
|
+
@show.setter
|
|
1308
|
+
def show(self, show):
|
|
1309
|
+
assignment = AssignOp.PlusEquals if show else AssignOp.MinusEquals
|
|
1310
|
+
session.set_style(self._indices, sv.ACTIVELINEMAPS,
|
|
1311
|
+
assignmodifier=assignment,
|
|
1312
|
+
uniqueid=self.plot.frame.uid)
|
|
1313
|
+
|
|
1314
|
+
@property
|
|
1315
|
+
def zone_index(self):
|
|
1316
|
+
"""`int`: Zero-based index of the `Zone <data_access>` this :ref:`Linemap` will draw.
|
|
1317
|
+
|
|
1318
|
+
Example usage::
|
|
1319
|
+
|
|
1320
|
+
>>> plot.linemap(0).zone_index = 2
|
|
1321
|
+
"""
|
|
1322
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.ZONE)
|
|
1323
|
+
|
|
1324
|
+
@zone_index.setter
|
|
1325
|
+
def zone_index(self, index):
|
|
1326
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.ZONE)
|
|
1327
|
+
|
|
1328
|
+
@property
|
|
1329
|
+
def show_in_legend(self):
|
|
1330
|
+
"""`LegendShow`: Show this :ref:`Linemap` in the legend.
|
|
1331
|
+
|
|
1332
|
+
Possible values:
|
|
1333
|
+
|
|
1334
|
+
`LegendShow.Always`
|
|
1335
|
+
The mapping appears in the legend even if the mapping is turned off
|
|
1336
|
+
(deactivated) or its entry in the table looks exactly like another
|
|
1337
|
+
mapping's entry.
|
|
1338
|
+
|
|
1339
|
+
`LegendShow.Never`
|
|
1340
|
+
The mapping never appears in the legend.
|
|
1341
|
+
|
|
1342
|
+
`LegendShow.Auto` (default)
|
|
1343
|
+
The mapping appears in the legend only when the mapping is turned
|
|
1344
|
+
on. If two mappings would result in the same entry in the legend,
|
|
1345
|
+
only one entry is shown.
|
|
1346
|
+
"""
|
|
1347
|
+
return self._get_style(LegendShow, sv.ASSIGN, sv.SHOWINLEGEND)
|
|
1348
|
+
|
|
1349
|
+
@show_in_legend.setter
|
|
1350
|
+
def show_in_legend(self, value):
|
|
1351
|
+
self._set_style(LegendShow(value or 1), sv.ASSIGN, sv.SHOWINLEGEND)
|
|
1352
|
+
|
|
1353
|
+
@property
|
|
1354
|
+
def sort_mode(self):
|
|
1355
|
+
"""`LineMapSort`: Control which `Variable` to use when sorting lines.
|
|
1356
|
+
|
|
1357
|
+
Possible values: `LineMapSort.BySpecificVar`,
|
|
1358
|
+
`LineMapSort.ByIndependentVar`, `LineMapSort.ByDependentVar` or
|
|
1359
|
+
`LineMapSort.None_`.
|
|
1360
|
+
|
|
1361
|
+
Example usage::
|
|
1362
|
+
|
|
1363
|
+
>>> from tecplot.constant import LineMapSort
|
|
1364
|
+
>>> plot.linemap(0).sort_mode = LineMapSort.ByDependentVar
|
|
1365
|
+
"""
|
|
1366
|
+
return self._get_style(LineMapSort, sv.ASSIGN, sv.SORT)
|
|
1367
|
+
|
|
1368
|
+
@sort_mode.setter
|
|
1369
|
+
def sort_mode(self, value):
|
|
1370
|
+
try:
|
|
1371
|
+
self._set_style(LineMapSort(value), sv.ASSIGN, sv.SORT)
|
|
1372
|
+
except TecplotSystemError:
|
|
1373
|
+
msg = textwrap.dedent('''\
|
|
1374
|
+
A variable must be set using sort_variable before the mode can
|
|
1375
|
+
be set to BySpecificVar''')
|
|
1376
|
+
raise TecplotLogicError(msg)
|
|
1377
|
+
|
|
1378
|
+
@property
|
|
1379
|
+
def sort_variable_index(self):
|
|
1380
|
+
"""`int`: Zero-based index of the specific `Variable` used for sorting.
|
|
1381
|
+
|
|
1382
|
+
The ``sort_mode`` attribute must be set to `LineMapSort.BySpecificVar`::
|
|
1383
|
+
|
|
1384
|
+
>>> from tecplot.constant import LineMapSort
|
|
1385
|
+
>>> plot.linemap(0).sort_by = LineMapSort.BySpecificVar
|
|
1386
|
+
>>> plot.linemap(0).sort_variable_index = 3
|
|
1387
|
+
"""
|
|
1388
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.SORTVAR)
|
|
1389
|
+
|
|
1390
|
+
@sort_variable_index.setter
|
|
1391
|
+
def sort_variable_index(self, value):
|
|
1392
|
+
self._set_style(tecutil.Index(value), sv.ASSIGN, sv.SORTVAR)
|
|
1393
|
+
|
|
1394
|
+
@property
|
|
1395
|
+
def sort_variable(self):
|
|
1396
|
+
"""`Variable`: Specific `Variable` used when listing lines.
|
|
1397
|
+
|
|
1398
|
+
The ``sort_mode`` attribute must be set to `LineMapSort.BySpecificVar`::
|
|
1399
|
+
|
|
1400
|
+
>>> from tecplot.constant import LineMapSort
|
|
1401
|
+
>>> plot.linemap(0).sort_by = LineMapSort.BySpecificVar
|
|
1402
|
+
>>> plot.linemap(0).sort_variable = dataset.variable('P')
|
|
1403
|
+
"""
|
|
1404
|
+
idx = self.sort_variable_index
|
|
1405
|
+
if isinstance(idx, Iterable):
|
|
1406
|
+
return tuple([self.plot.frame.dataset.variable(i) for i in idx])
|
|
1407
|
+
else:
|
|
1408
|
+
return self.plot.frame.dataset.variable(idx)
|
|
1409
|
+
|
|
1410
|
+
@sort_variable.setter
|
|
1411
|
+
def sort_variable(self, value):
|
|
1412
|
+
self.sort_variable_index = value.index
|
|
1413
|
+
|
|
1414
|
+
@property
|
|
1415
|
+
def curve(self):
|
|
1416
|
+
"""`LinemapCurve`: Style and fitting-method control for lines.
|
|
1417
|
+
"""
|
|
1418
|
+
return LinemapCurve(self)
|
|
1419
|
+
|
|
1420
|
+
@property
|
|
1421
|
+
def indices(self):
|
|
1422
|
+
"""`LinemapIndices`: Object controlling which lines are shown.
|
|
1423
|
+
"""
|
|
1424
|
+
return LinemapIndices(self)
|
|
1425
|
+
|
|
1426
|
+
@property
|
|
1427
|
+
def line(self):
|
|
1428
|
+
"""`LinemapLine`: Style for lines to be drawn.
|
|
1429
|
+
"""
|
|
1430
|
+
return LinemapLine(self)
|
|
1431
|
+
|
|
1432
|
+
@property
|
|
1433
|
+
def symbols(self):
|
|
1434
|
+
"""`LinemapSymbols`: Style for markers at points along the lines.
|
|
1435
|
+
"""
|
|
1436
|
+
return LinemapSymbols(self)
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
class Linemap(LinemapCollection):
|
|
1440
|
+
def _get_style(self, rettype, *svargs, **kwargs):
|
|
1441
|
+
return super()._get_style(rettype, *svargs, **kwargs)[0]
|
|
1442
|
+
|
|
1443
|
+
@property
|
|
1444
|
+
def index(self):
|
|
1445
|
+
"""`int`: Zero-based integer identifier for this :ref:`Linemap`.
|
|
1446
|
+
|
|
1447
|
+
Example::
|
|
1448
|
+
|
|
1449
|
+
>>> lmap = plot.linemap(1)
|
|
1450
|
+
>>> print(lmap.index)
|
|
1451
|
+
1
|
|
1452
|
+
"""
|
|
1453
|
+
return next(iter(self._indices))
|
|
1454
|
+
|
|
1455
|
+
@property
|
|
1456
|
+
def aux_data(self):
|
|
1457
|
+
"""Auxiliary data for this linemap.
|
|
1458
|
+
|
|
1459
|
+
Returns: `AuxData`
|
|
1460
|
+
|
|
1461
|
+
This is the auxiliary data attached to the linemap. Such data is
|
|
1462
|
+
written to the layout file by default and can be retrieved later.
|
|
1463
|
+
Example usage::
|
|
1464
|
+
|
|
1465
|
+
>>> from tecplot.constant import PlotType
|
|
1466
|
+
>>> plot = tp.active_frame().plot(PlotType.XYLine)
|
|
1467
|
+
>>> aux = plot.linemap(0).aux_data
|
|
1468
|
+
>>> aux['Result'] = '3.14159'
|
|
1469
|
+
>>> print(aux['Result'])
|
|
1470
|
+
3.14159
|
|
1471
|
+
"""
|
|
1472
|
+
return session.AuxData(self.plot.frame, AuxDataObjectType.Linemap,
|
|
1473
|
+
self.index)
|
|
1474
|
+
@property
|
|
1475
|
+
def show(self):
|
|
1476
|
+
"""`bool`: Display this linemap on the plot.
|
|
1477
|
+
|
|
1478
|
+
Example usage for turning on all linemaps::
|
|
1479
|
+
|
|
1480
|
+
>>> for lmap in plot.linemaps():
|
|
1481
|
+
... lmap.show = True
|
|
1482
|
+
"""
|
|
1483
|
+
return self._indices.issubset(self.plot.active_linemap_indices)
|
|
1484
|
+
|
|
1485
|
+
@show.setter
|
|
1486
|
+
def show(self, show):
|
|
1487
|
+
assignment = AssignOp.PlusEquals if show else AssignOp.MinusEquals
|
|
1488
|
+
session.set_style(self._indices, sv.ACTIVELINEMAPS,
|
|
1489
|
+
assignmodifier=assignment,
|
|
1490
|
+
uniqueid=self.plot.frame.uid)
|
|
1491
|
+
|
|
1492
|
+
@property
|
|
1493
|
+
def zone(self):
|
|
1494
|
+
"""Data source (`Zone <data_access>`) for this :ref:`Linemap`.
|
|
1495
|
+
|
|
1496
|
+
Example usage::
|
|
1497
|
+
|
|
1498
|
+
>>> plot.linemap(0).zone = dataset.zone('Zone 1')
|
|
1499
|
+
"""
|
|
1500
|
+
return self.plot.frame.dataset.zone(self.zone_index)
|
|
1501
|
+
|
|
1502
|
+
@zone.setter
|
|
1503
|
+
def zone(self, zone):
|
|
1504
|
+
self.zone_index = getattr(zone, 'index', zone)
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
class XYLinemapCollection(LinemapCollection):
|
|
1508
|
+
"""Data mapping and style control for one or more line plots.
|
|
1509
|
+
|
|
1510
|
+
This class behaves like `XYLinemap` except that setting any underlying
|
|
1511
|
+
style will do so for all of the represented linemaps. The style
|
|
1512
|
+
properties are then always returned as a `tuple` of properties, one for
|
|
1513
|
+
each linemap, ordered by index number. This means there is an asymmetry
|
|
1514
|
+
between setting and getting any property under this object, illustrated
|
|
1515
|
+
by the following example::
|
|
1516
|
+
|
|
1517
|
+
>>> lmaps = plot.linemaps(0, 1, 2)
|
|
1518
|
+
>>> lmaps.show = True
|
|
1519
|
+
>>> print(lmaps.show)
|
|
1520
|
+
(True, True, True)
|
|
1521
|
+
|
|
1522
|
+
This is the preferred way to control the style of many linemaps as it
|
|
1523
|
+
is much faster to execute. All examples that set style on a single
|
|
1524
|
+
linemap like the following::
|
|
1525
|
+
|
|
1526
|
+
>>> plot.linemap(0).line.color = Color.Blue
|
|
1527
|
+
|
|
1528
|
+
may be converted to setting the same style on all linemaps like so::
|
|
1529
|
+
|
|
1530
|
+
>>> plot.linemaps().line.color = Color.Blue
|
|
1531
|
+
|
|
1532
|
+
.. versionadded:: 1.1
|
|
1533
|
+
Linemap collection objects.
|
|
1534
|
+
|
|
1535
|
+
The Linemap layer controls how ordered or connected data is represented.
|
|
1536
|
+
This may be either a set of line segments connecting all the data points,
|
|
1537
|
+
or a curve fitted to the original data. This object represents one or more
|
|
1538
|
+
linemaps and can conveniently control the style for each one.
|
|
1539
|
+
|
|
1540
|
+
.. code-block:: python
|
|
1541
|
+
:emphasize-lines: 23-26,29-31
|
|
1542
|
+
|
|
1543
|
+
from os import path
|
|
1544
|
+
import tecplot as tp
|
|
1545
|
+
from tecplot.constant import PlotType, Color, LinePattern, AxisTitleMode
|
|
1546
|
+
|
|
1547
|
+
# load data from examples directory
|
|
1548
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
1549
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
1550
|
+
dataset = tp.data.load_tecplot(infile)
|
|
1551
|
+
|
|
1552
|
+
# get handle to the active frame and set plot type to XY Line
|
|
1553
|
+
frame = tp.active_frame()
|
|
1554
|
+
frame.plot_type = PlotType.XYLine
|
|
1555
|
+
plot = frame.plot()
|
|
1556
|
+
|
|
1557
|
+
# We will set the name, color and a few other properties
|
|
1558
|
+
# for the first three linemaps in the dataset.
|
|
1559
|
+
names = ['Seattle', 'Dallas', 'Miami']
|
|
1560
|
+
colors = [Color.Blue, Color.DeepRed, Color.Khaki]
|
|
1561
|
+
|
|
1562
|
+
lmaps = plot.linemaps()
|
|
1563
|
+
|
|
1564
|
+
# set common style for all linemaps in the collection
|
|
1565
|
+
lmaps.show = True
|
|
1566
|
+
lmaps.line.line_thickness = 1
|
|
1567
|
+
lmaps.line.line_pattern = LinePattern.LongDash
|
|
1568
|
+
lmaps.line.pattern_length = 2
|
|
1569
|
+
|
|
1570
|
+
# loop over the linemaps, setting name and color for each
|
|
1571
|
+
for lmap, name, color in zip(lmaps, names, colors):
|
|
1572
|
+
lmap.name = name
|
|
1573
|
+
lmap.line.color = color
|
|
1574
|
+
|
|
1575
|
+
# Set the y-axis label
|
|
1576
|
+
plot.axes.y_axis(0).title.title_mode = AxisTitleMode.UseText
|
|
1577
|
+
plot.axes.y_axis(0).title.text = 'Rainfall'
|
|
1578
|
+
|
|
1579
|
+
# Turn on legend
|
|
1580
|
+
plot.legend.show = True
|
|
1581
|
+
|
|
1582
|
+
# Adjust the axes limits to show all the data
|
|
1583
|
+
plot.view.fit()
|
|
1584
|
+
|
|
1585
|
+
# save image to file
|
|
1586
|
+
tp.export.save_png('linemap.png', 600, supersample=3)
|
|
1587
|
+
|
|
1588
|
+
.. figure:: /_static/images/linemap.png
|
|
1589
|
+
:width: 300px
|
|
1590
|
+
:figwidth: 300px
|
|
1591
|
+
"""
|
|
1592
|
+
def __getitem__(self, index):
|
|
1593
|
+
return XYLinemap(self.plot, self.linemap_indices[index])
|
|
1594
|
+
|
|
1595
|
+
@property
|
|
1596
|
+
def x_axis_index(self):
|
|
1597
|
+
"""`int`: Zero-based index of the x-axis used by this linemap.
|
|
1598
|
+
|
|
1599
|
+
Example usage::
|
|
1600
|
+
|
|
1601
|
+
>>> plot.linemap(0).x_axis_index = 2
|
|
1602
|
+
"""
|
|
1603
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.XAXIS)
|
|
1604
|
+
|
|
1605
|
+
@x_axis_index.setter
|
|
1606
|
+
def x_axis_index(self, index):
|
|
1607
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.XAXIS)
|
|
1608
|
+
|
|
1609
|
+
@property
|
|
1610
|
+
def x_axis(self):
|
|
1611
|
+
"""`XYLineAxis`: The X-axis used by this linemap.
|
|
1612
|
+
|
|
1613
|
+
Example usage::
|
|
1614
|
+
|
|
1615
|
+
>>> plot.linemap(0).x_axis = plot.axes.x_axis(2)
|
|
1616
|
+
"""
|
|
1617
|
+
return self.plot.axes.x_axis(self.x_axis_index)
|
|
1618
|
+
|
|
1619
|
+
@x_axis.setter
|
|
1620
|
+
def x_axis(self, axis):
|
|
1621
|
+
self.x_axis_index = axis.index
|
|
1622
|
+
|
|
1623
|
+
@property
|
|
1624
|
+
def y_axis_index(self):
|
|
1625
|
+
"""`int`: Zero-based index of the y-axis used by this linemap.
|
|
1626
|
+
|
|
1627
|
+
Example usage::
|
|
1628
|
+
|
|
1629
|
+
>>> plot.linemap(0).y_axis_index = 2
|
|
1630
|
+
"""
|
|
1631
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.YAXIS)
|
|
1632
|
+
|
|
1633
|
+
@y_axis_index.setter
|
|
1634
|
+
def y_axis_index(self, index):
|
|
1635
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.YAXIS)
|
|
1636
|
+
|
|
1637
|
+
@property
|
|
1638
|
+
def y_axis(self):
|
|
1639
|
+
"""`XYLineAxis`: Y-axis used by this linemap.
|
|
1640
|
+
|
|
1641
|
+
Example usage::
|
|
1642
|
+
|
|
1643
|
+
>>> plot.linemap(0).x_axis = plot.axes.y_axis(2)
|
|
1644
|
+
"""
|
|
1645
|
+
return self.plot.axes.y_axis(self.y_axis_index)
|
|
1646
|
+
|
|
1647
|
+
@y_axis.setter
|
|
1648
|
+
def y_axis(self, axis):
|
|
1649
|
+
self.y_axis_index = axis.index
|
|
1650
|
+
|
|
1651
|
+
@property
|
|
1652
|
+
def x_variable_index(self):
|
|
1653
|
+
"""`int`: Zero-based index of the `Variable` used for x-positions.
|
|
1654
|
+
|
|
1655
|
+
Example usage::
|
|
1656
|
+
|
|
1657
|
+
>>> plot.linemap(0).x_variable_index = 2
|
|
1658
|
+
"""
|
|
1659
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.XAXISVAR)
|
|
1660
|
+
|
|
1661
|
+
@x_variable_index.setter
|
|
1662
|
+
def x_variable_index(self, index):
|
|
1663
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.XAXISVAR)
|
|
1664
|
+
|
|
1665
|
+
@property
|
|
1666
|
+
def x_variable(self):
|
|
1667
|
+
"""`Variable`: `Variable` used for x-positions of this linemap.
|
|
1668
|
+
|
|
1669
|
+
Example usage::
|
|
1670
|
+
|
|
1671
|
+
>>> plot.linemap(0).x_variable = dataset.variable('P')
|
|
1672
|
+
"""
|
|
1673
|
+
return self.plot.frame.dataset.variable(self.x_variable_index)
|
|
1674
|
+
|
|
1675
|
+
@x_variable.setter
|
|
1676
|
+
def x_variable(self, variable):
|
|
1677
|
+
self.x_variable_index = variable.index
|
|
1678
|
+
|
|
1679
|
+
@property
|
|
1680
|
+
def y_variable_index(self):
|
|
1681
|
+
"""`int`: Zero-based index of the `Variable` used for y-positions.
|
|
1682
|
+
|
|
1683
|
+
Example usage::
|
|
1684
|
+
|
|
1685
|
+
>>> plot.linemap(0).y_variable_index = 2
|
|
1686
|
+
"""
|
|
1687
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.YAXISVAR)
|
|
1688
|
+
|
|
1689
|
+
@y_variable_index.setter
|
|
1690
|
+
def y_variable_index(self, index):
|
|
1691
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.YAXISVAR)
|
|
1692
|
+
|
|
1693
|
+
@property
|
|
1694
|
+
def y_variable(self):
|
|
1695
|
+
"""`Variable`: `Variable` used for y-positions of this linemap.
|
|
1696
|
+
|
|
1697
|
+
Example usage::
|
|
1698
|
+
|
|
1699
|
+
>>> plot.linemap(0).y_variable = dataset.variable('Q')
|
|
1700
|
+
"""
|
|
1701
|
+
return self.plot.frame.dataset.variable(self.y_variable_index)
|
|
1702
|
+
|
|
1703
|
+
@y_variable.setter
|
|
1704
|
+
def y_variable(self, variable):
|
|
1705
|
+
self.y_variable_index = variable.index
|
|
1706
|
+
|
|
1707
|
+
@property
|
|
1708
|
+
def function_dependency(self):
|
|
1709
|
+
"""`FunctionDependency`: The independent variable for function evalulation.
|
|
1710
|
+
|
|
1711
|
+
Possible values: `XIndependent`, `YIndependent`.
|
|
1712
|
+
|
|
1713
|
+
Example usage::
|
|
1714
|
+
|
|
1715
|
+
>>> from tecplot.constant import FunctionDependency
|
|
1716
|
+
>>> lmap = plot.linemap(0)
|
|
1717
|
+
>>> lmap.function_dependency = FunctionDependency.YIndependent
|
|
1718
|
+
"""
|
|
1719
|
+
return self._get_style(FunctionDependency, sv.ASSIGN,
|
|
1720
|
+
sv.FUNCTIONDEPENDENCY)
|
|
1721
|
+
|
|
1722
|
+
@function_dependency.setter
|
|
1723
|
+
def function_dependency(self, value):
|
|
1724
|
+
self._set_style(FunctionDependency(value), sv.ASSIGN,
|
|
1725
|
+
sv.FUNCTIONDEPENDENCY)
|
|
1726
|
+
|
|
1727
|
+
@property
|
|
1728
|
+
def bars(self):
|
|
1729
|
+
"""`LinemapBars`: `LinemapBars` style for bar charts.
|
|
1730
|
+
"""
|
|
1731
|
+
return LinemapBars(self)
|
|
1732
|
+
|
|
1733
|
+
@property
|
|
1734
|
+
def error_bars(self):
|
|
1735
|
+
"""`LinemapErrorBars`: `LinemapErrorBars` style for error bars.
|
|
1736
|
+
"""
|
|
1737
|
+
return LinemapErrorBars(self)
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
class PolarLinemapCollection(LinemapCollection):
|
|
1741
|
+
"""Data mapping and style control for one or more polar line plots.
|
|
1742
|
+
|
|
1743
|
+
.. versionadded:: 1.1
|
|
1744
|
+
Linemap collection objects.
|
|
1745
|
+
"""
|
|
1746
|
+
def __getitem__(self, index):
|
|
1747
|
+
return PolarLinemap(self.plot, self.linemap_indices[index])
|
|
1748
|
+
|
|
1749
|
+
@property
|
|
1750
|
+
def r_axis(self):
|
|
1751
|
+
"""`RadialLineAxis`: Radial axis used by this linemap.
|
|
1752
|
+
|
|
1753
|
+
Example usage::
|
|
1754
|
+
|
|
1755
|
+
>>> from tecplot.constant import PlotType
|
|
1756
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1757
|
+
>>> plot.linemap(0).r_axis.title = 'distance (m)'
|
|
1758
|
+
"""
|
|
1759
|
+
return self.plot.axes.r_axis
|
|
1760
|
+
|
|
1761
|
+
@property
|
|
1762
|
+
def theta_axis(self):
|
|
1763
|
+
"""`PolarAngleLineAxis`: Angular axis used by this linemap.
|
|
1764
|
+
|
|
1765
|
+
Example usage::
|
|
1766
|
+
|
|
1767
|
+
>>> from tecplot.constant import PlotType
|
|
1768
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1769
|
+
>>> plot.linemap(0).theta_axis.title = 'angle (deg)'
|
|
1770
|
+
"""
|
|
1771
|
+
return self.plot.axes.theta_axis
|
|
1772
|
+
|
|
1773
|
+
@property
|
|
1774
|
+
def r_variable_index(self):
|
|
1775
|
+
"""`int` (Zero-based index): :math:`r`-component `Variable` index of the plotted line.
|
|
1776
|
+
|
|
1777
|
+
Example usage::
|
|
1778
|
+
|
|
1779
|
+
>>> from tecplot.constant import PlotType
|
|
1780
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1781
|
+
>>> plot.linemap(0).r_variable_index = 0
|
|
1782
|
+
"""
|
|
1783
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.RAXISVAR)
|
|
1784
|
+
|
|
1785
|
+
@r_variable_index.setter
|
|
1786
|
+
def r_variable_index(self, index):
|
|
1787
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.RAXISVAR)
|
|
1788
|
+
|
|
1789
|
+
@property
|
|
1790
|
+
def r_variable(self):
|
|
1791
|
+
"""`Variable`: :math:`r`-component `Variable` of the plotted line.
|
|
1792
|
+
|
|
1793
|
+
Example usage::
|
|
1794
|
+
|
|
1795
|
+
>>> from tecplot.constant import PlotType
|
|
1796
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1797
|
+
>>> plot.linemap(0).r_variable = dataset.variable('R')
|
|
1798
|
+
"""
|
|
1799
|
+
return self.plot.frame.dataset.variable(self.r_variable_index)
|
|
1800
|
+
|
|
1801
|
+
@r_variable.setter
|
|
1802
|
+
def r_variable(self, variable):
|
|
1803
|
+
self.r_variable_index = variable.index
|
|
1804
|
+
|
|
1805
|
+
@property
|
|
1806
|
+
def theta_variable_index(self):
|
|
1807
|
+
"""`int` (Zero-based index): :math:`\theta`-component `Variable` index of the plotted line.
|
|
1808
|
+
|
|
1809
|
+
Example usage::
|
|
1810
|
+
|
|
1811
|
+
>>> from tecplot.constant import PlotType
|
|
1812
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1813
|
+
>>> plot.linemap(0).theta_variable_index = 1
|
|
1814
|
+
"""
|
|
1815
|
+
return self._get_style(tecutil.Index, sv.ASSIGN, sv.THETAAXISVAR)
|
|
1816
|
+
|
|
1817
|
+
@theta_variable_index.setter
|
|
1818
|
+
def theta_variable_index(self, index):
|
|
1819
|
+
self._set_style(tecutil.Index(index), sv.ASSIGN, sv.THETAAXISVAR)
|
|
1820
|
+
|
|
1821
|
+
@property
|
|
1822
|
+
def theta_variable(self):
|
|
1823
|
+
"""`Variable`: :math:`\theta`-component `Variable` of the plotted line.
|
|
1824
|
+
|
|
1825
|
+
Example usage::
|
|
1826
|
+
|
|
1827
|
+
>>> from tecplot.constant import PlotType
|
|
1828
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1829
|
+
>>> plot.linemap(0).theta_variable = dataset.variable('Theta')
|
|
1830
|
+
"""
|
|
1831
|
+
return self.plot.frame.dataset.variable(self.theta_variable_index)
|
|
1832
|
+
|
|
1833
|
+
@theta_variable.setter
|
|
1834
|
+
def theta_variable(self, variable):
|
|
1835
|
+
self.theta_variable_index = variable.index
|
|
1836
|
+
|
|
1837
|
+
@property
|
|
1838
|
+
def function_dependency(self):
|
|
1839
|
+
"""`FunctionDependency`: The independent variable for function evalulation.
|
|
1840
|
+
|
|
1841
|
+
Possible values: ``RIndependent``, ``ThetaIndependent``. Example
|
|
1842
|
+
usage::
|
|
1843
|
+
|
|
1844
|
+
>>> from tecplot.constant import FunctionDependency, PlotType
|
|
1845
|
+
>>> plot = frame.plot(PlotType.PolarLine)
|
|
1846
|
+
>>> lmap = plot.linemap(0)
|
|
1847
|
+
>>> lmap.function_dependency = FunctionDependency.ThetaIndependent
|
|
1848
|
+
"""
|
|
1849
|
+
return self._get_style(FunctionDependency, sv.ASSIGN,
|
|
1850
|
+
sv.FUNCTIONDEPENDENCY)
|
|
1851
|
+
|
|
1852
|
+
@function_dependency.setter
|
|
1853
|
+
def function_dependency(self, value):
|
|
1854
|
+
self._set_style(FunctionDependency(value), sv.ASSIGN,
|
|
1855
|
+
sv.FUNCTIONDEPENDENCY)
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
class XYLinemap(Linemap, XYLinemapCollection):
|
|
1859
|
+
"""Data mapping and style control for 2D Cartesian line plots.
|
|
1860
|
+
|
|
1861
|
+
Linemaps connect a specific `Zone <data_access>`/`Variable` combination to
|
|
1862
|
+
a line or set of lines, depending on the dimension of the data if ordered.
|
|
1863
|
+
Linemaps can share any of the axes available in the plot and orientation
|
|
1864
|
+
can be verical or horizontal by setting the independent variable with
|
|
1865
|
+
`XYLinemap.function_dependency`:
|
|
1866
|
+
|
|
1867
|
+
.. code-block:: python
|
|
1868
|
+
:emphasize-lines: 13-23
|
|
1869
|
+
|
|
1870
|
+
from os import path
|
|
1871
|
+
import tecplot as tp
|
|
1872
|
+
from tecplot.constant import PlotType, Color
|
|
1873
|
+
|
|
1874
|
+
examples_dir = tp.session.tecplot_examples_directory()
|
|
1875
|
+
infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
|
|
1876
|
+
dataset = tp.data.load_tecplot(infile)
|
|
1877
|
+
|
|
1878
|
+
frame = tp.active_frame()
|
|
1879
|
+
frame.plot_type = PlotType.XYLine
|
|
1880
|
+
plot = frame.plot()
|
|
1881
|
+
|
|
1882
|
+
lmap = plot.linemap(0)
|
|
1883
|
+
lmap.line.line_thickness = 0.8
|
|
1884
|
+
lmap.line.color = Color.DeepRed
|
|
1885
|
+
lmap.y_axis.title.color = Color.DeepRed
|
|
1886
|
+
|
|
1887
|
+
lmap = plot.linemap(1)
|
|
1888
|
+
lmap.show = True
|
|
1889
|
+
lmap.y_axis_index = 1
|
|
1890
|
+
lmap.line.line_thickness = 0.8
|
|
1891
|
+
lmap.line.color = Color.Blue
|
|
1892
|
+
lmap.y_axis.title.color = lmap.line.color
|
|
1893
|
+
|
|
1894
|
+
tp.export.save_png('linemap_xy.png', 600, supersample=3)
|
|
1895
|
+
|
|
1896
|
+
.. figure:: /_static/images/linemap_xy.png
|
|
1897
|
+
:width: 300px
|
|
1898
|
+
:figwidth: 300px
|
|
1899
|
+
|
|
1900
|
+
.. seealso:: `XYLinemapCollection`
|
|
1901
|
+
"""
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
class PolarLinemap(Linemap, PolarLinemapCollection):
|
|
1905
|
+
"""Data mapping and style control for polar line plots."""
|