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.
Files changed (97) hide show
  1. pytecplot-1.5.2.dist-info/LICENSE.html +77 -0
  2. pytecplot-1.5.2.dist-info/METADATA +508 -0
  3. pytecplot-1.5.2.dist-info/RECORD +97 -0
  4. pytecplot-1.5.2.dist-info/WHEEL +5 -0
  5. pytecplot-1.5.2.dist-info/top_level.txt +1 -0
  6. tecplot/__init__.py +94 -0
  7. tecplot/annotation/__init__.py +7 -0
  8. tecplot/annotation/annotation.py +223 -0
  9. tecplot/annotation/geometry.py +369 -0
  10. tecplot/annotation/georeference.py +33 -0
  11. tecplot/annotation/image.py +185 -0
  12. tecplot/annotation/iter.py +105 -0
  13. tecplot/annotation/polyline.py +381 -0
  14. tecplot/annotation/text.py +744 -0
  15. tecplot/constant.py +401 -0
  16. tecplot/data/__init__.py +34 -0
  17. tecplot/data/array.py +645 -0
  18. tecplot/data/create.py +1 -0
  19. tecplot/data/dataset.py +1809 -0
  20. tecplot/data/extract.py +544 -0
  21. tecplot/data/face_neighbors.py +494 -0
  22. tecplot/data/facemap.py +814 -0
  23. tecplot/data/load.py +2075 -0
  24. tecplot/data/nodemap.py +577 -0
  25. tecplot/data/operate.py +928 -0
  26. tecplot/data/query.py +334 -0
  27. tecplot/data/save.py +343 -0
  28. tecplot/data/variable.py +280 -0
  29. tecplot/data/zone.py +841 -0
  30. tecplot/exception.py +201 -0
  31. tecplot/export/__init__.py +13 -0
  32. tecplot/export/animation.py +521 -0
  33. tecplot/export/export_setup.py +318 -0
  34. tecplot/export/image.py +577 -0
  35. tecplot/export/print_setup.py +218 -0
  36. tecplot/export/time_animation.py +607 -0
  37. tecplot/extension/__init__.py +14 -0
  38. tecplot/extension/ipython.py +68 -0
  39. tecplot/layout/__init__.py +20 -0
  40. tecplot/layout/frame.py +1285 -0
  41. tecplot/layout/layout.py +488 -0
  42. tecplot/layout/page.py +541 -0
  43. tecplot/legend/__init__.py +4 -0
  44. tecplot/legend/contour_legend.py +516 -0
  45. tecplot/legend/legend.py +141 -0
  46. tecplot/legend/line_legend.py +66 -0
  47. tecplot/legend/rgb_coloring_legend.py +291 -0
  48. tecplot/legend/scatter_legend.py +136 -0
  49. tecplot/macro.py +339 -0
  50. tecplot/plot/__init__.py +62 -0
  51. tecplot/plot/axes.py +881 -0
  52. tecplot/plot/axis.py +1350 -0
  53. tecplot/plot/blanking.py +584 -0
  54. tecplot/plot/contour.py +1302 -0
  55. tecplot/plot/effects.py +162 -0
  56. tecplot/plot/fieldmap.py +2159 -0
  57. tecplot/plot/grid.py +758 -0
  58. tecplot/plot/isosurface.py +1167 -0
  59. tecplot/plot/labels.py +338 -0
  60. tecplot/plot/linemap.py +1905 -0
  61. tecplot/plot/linking.py +489 -0
  62. tecplot/plot/plot.py +1791 -0
  63. tecplot/plot/rgb_coloring.py +281 -0
  64. tecplot/plot/scatter.py +396 -0
  65. tecplot/plot/slice.py +1544 -0
  66. tecplot/plot/streamtrace.py +1949 -0
  67. tecplot/plot/symbol.py +567 -0
  68. tecplot/plot/ticks.py +666 -0
  69. tecplot/plot/title.py +380 -0
  70. tecplot/plot/vector.py +679 -0
  71. tecplot/plot/view.py +868 -0
  72. tecplot/session/__init__.py +112 -0
  73. tecplot/session/aux_data.py +276 -0
  74. tecplot/session/config.py +92 -0
  75. tecplot/session/session.py +425 -0
  76. tecplot/session/state_changed.py +225 -0
  77. tecplot/session/style.py +504 -0
  78. tecplot/tecutil/__init__.py +16 -0
  79. tecplot/tecutil/arglist.py +230 -0
  80. tecplot/tecutil/captured_output.py +177 -0
  81. tecplot/tecutil/constant.py +1312 -0
  82. tecplot/tecutil/index_set.py +118 -0
  83. tecplot/tecutil/lock.py +36 -0
  84. tecplot/tecutil/message_pb2.py +39 -0
  85. tecplot/tecutil/preamble.py +54 -0
  86. tecplot/tecutil/stringlist.py +114 -0
  87. tecplot/tecutil/sv.py +1662 -0
  88. tecplot/tecutil/tecutil.py +12402 -0
  89. tecplot/tecutil/tecutil_client.py +627 -0
  90. tecplot/tecutil/tecutil_connector.py +937 -0
  91. tecplot/tecutil/tecutil_rpc.py +6845 -0
  92. tecplot/tecutil/util.py +332 -0
  93. tecplot/text/__init__.py +3 -0
  94. tecplot/text/font.py +224 -0
  95. tecplot/text/label_format.py +374 -0
  96. tecplot/text/textbox.py +106 -0
  97. tecplot/version.py +41 -0
tecplot/plot/axis.py ADDED
@@ -0,0 +1,1350 @@
1
+ import ctypes
2
+
3
+ from ..tecutil import _tecutil
4
+ from ..constant import *
5
+ from ..exception import *
6
+ from .. import macro, session, tecutil
7
+ from ..tecutil import Index, lock, lock_attributes, sv
8
+ from .grid import (GridLines, GridLines2D, MarkerGridLine, MarkerGridLine2D,
9
+ MinorGridLines, MinorGridLines2D, PolarAngleGridLines,
10
+ PolarAngleMarkerGridLine, PolarAngleMinorGridLines)
11
+ from .ticks import (RadialTicks, RadialTickLabels, TickLabels2D, TickLabels3D,
12
+ Ticks2D, Ticks3D)
13
+ from .title import (Axis2DTitle, DataAxis2DTitle, DataAxis3DTitle,
14
+ RadialAxisTitle)
15
+
16
+
17
+ class Axis(session.Style):
18
+ def __init__(self, axes, name, **kwargs):
19
+ self.axes = axes
20
+ self.name, self._sv_name, self._sv_detail = Axis._sv_axis_detail(name)
21
+ kw = axes._kw
22
+ kw.update(**kwargs)
23
+ super().__init__(axes._sv, self._sv_detail, **kw)
24
+
25
+ @staticmethod
26
+ def _sv_axis_detail(name):
27
+ if isinstance(name, str):
28
+ name = name.upper()
29
+ svname = getattr(sv, name)
30
+ svdetail = getattr(sv, name+'DETAIL')
31
+ else:
32
+ _tr = {sv.X: 'X', sv.Y: 'Y', sv.Z: 'Z', sv.R: 'R',
33
+ sv.THETA: 'THETA'}
34
+ _tr_detail = {sv.X: sv.XDETAIL, sv.Y: sv.YDETAIL, sv.Z: sv.ZDETAIL,
35
+ sv.R: sv.RDETAIL, sv.THETA: sv.THETADETAIL}
36
+ svdetail = _tr_detail[name]
37
+ svname = name
38
+ name = _tr[svname]
39
+ return name, svname, svdetail
40
+
41
+ def __eq__(self, that):
42
+ return (isinstance(that, type(self)) and self.name == that.name and
43
+ self.axes == that.axes)
44
+
45
+ def __ne__(self, that):
46
+ return not (self == that)
47
+
48
+ @lock()
49
+ def _view(self, action, consider_blanking=None):
50
+ """Internal implementation for all view actions which take a single
51
+ consider blanking parameter."""
52
+ with self.axes.plot.frame.activated():
53
+ with tecutil.ArgList() as arg_list:
54
+ arg_list[sv.VIEWOP] = action
55
+ arg_list[sv.AXIS] = ord(self.name[0])
56
+ arg_list[sv.AXISNUM] = getattr(self, 'index', 0) + 1
57
+ if consider_blanking:
58
+ arg_list[sv.CONSIDERBLANKING] = True
59
+ if not _tecutil.ViewX(arg_list):
60
+ raise TecplotSystemError()
61
+
62
+ @property
63
+ def show(self):
64
+ """`bool`: Enable drawing of this axis.
65
+
66
+ Example usage::
67
+
68
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
69
+ >>> # or "plot.axes.x_axis" for field or sketch plots
70
+ >>> axis.show = True
71
+ """
72
+ return self._get_style(bool, sv.SHOWAXIS)
73
+
74
+ @show.setter
75
+ def show(self, show):
76
+ self._set_style(bool(show), sv.SHOWAXIS)
77
+
78
+ @property
79
+ def min(self):
80
+ """`float`: Lower bound of this axis' range.
81
+
82
+ Example usage::
83
+
84
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
85
+ >>> # or "plot.axes.x_axis" for field or sketch plots
86
+ >>> axis.min = 0.0
87
+ """
88
+ return self._get_style(float, sv.RANGEMIN)
89
+
90
+ @min.setter
91
+ def min(self, value):
92
+ # This is a work around for handling an uninitialized range
93
+ # for the sketch axes. We set both min and max using a
94
+ # macro which allows us to set the min and max individually.
95
+ # Also, it prevents the range from being reset as the result
96
+ # of uninitialized conditions in the engine with dynamically
97
+ # created axis variables. (See TargetProcess request: 106803)
98
+ fmt = '$!{} {}Detail {{ RangeMin = {} RangeMax = {} }}'
99
+ cmd = fmt.format(self._sv[0], self.name, float(value), self.max)
100
+ macro.execute_command(cmd)
101
+ self._set_style(float(value), sv.RANGEMIN)
102
+
103
+ @property
104
+ def max(self):
105
+ """`float`: Upper bound of this axis' range.
106
+
107
+ Example usage::
108
+
109
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
110
+ >>> # or "plot.axes.x_axis" for field or sketch plots
111
+ >>> axis.max = 1.0
112
+ """
113
+ return self._get_style(float, sv.RANGEMAX)
114
+
115
+ @max.setter
116
+ def max(self, value):
117
+ # This is a work around for handling an uninitialized range
118
+ # for the sketch axes. We set both min and max using a
119
+ # macro which allows us to set the min and max individually.
120
+ # Also, it prevents the range from being reset as the result
121
+ # of uninitialized conditions in the engine with dynamically
122
+ # created axis variables. (See TargetProcess request: 106803)
123
+ fmt = '$!{} {}Detail {{ RangeMin = {} RangeMax = {} }}'
124
+ cmd = fmt.format(self._sv[0], self.name, self.min, float(value))
125
+ macro.execute_command(cmd)
126
+ self._set_style(float(value), sv.RANGEMAX)
127
+
128
+ @property
129
+ def ticks(self):
130
+ """`Ticks2D`: Axis major and minor ticks style control.
131
+
132
+ Example usage::
133
+
134
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
135
+ >>> # or "plot.axes.x_axis" for field or sketch plots
136
+ >>> axis.ticks.line_thickness = 0.8
137
+ """
138
+ return Ticks2D(self)
139
+
140
+ @property
141
+ def tick_labels(self):
142
+ """`TickLabels2D`: Axis ticks labels style control.
143
+
144
+ Example usage::
145
+
146
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
147
+ >>> # or "plot.axes.x_axis" for field or sketch plots
148
+ >>> axis.tick_labels.show = False
149
+ """
150
+ return TickLabels2D(self)
151
+
152
+ @property
153
+ def grid_lines(self):
154
+ """`GridLines2D`: Major grid lines style control.
155
+
156
+ Major grid lines are attached to the locations of the major ticks. See
157
+ `minor_grid_lines <XYLineAxis.minor_grid_lines>` for lines attached to
158
+ minor ticks. Example usage::
159
+
160
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
161
+ >>> # or "plot.axes.x_axis" for field or sketch plots
162
+ >>> axis.grid_lines.show = True
163
+ """
164
+ return GridLines2D(self)
165
+
166
+ @property
167
+ def minor_grid_lines(self):
168
+ """`MinorGridLines2D`: Minor grid lines style control.
169
+
170
+ Minor grid lines are attached to the locations of the minor ticks.
171
+ Example usage::
172
+
173
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
174
+ >>> # or "plot.axes.x_axis" for field or sketch plots
175
+ >>> axis.minor_grid_lines.show = True
176
+ """
177
+ return MinorGridLines2D(self)
178
+
179
+ @property
180
+ def title(self):
181
+ """`str`: Axis title.
182
+
183
+ This is the primary label for the axis and usually includes units::
184
+
185
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
186
+ >>> # or "plot.axes.x_axis" for field or sketch plots
187
+ >>> axis.title.text = 'distance (m)'
188
+ """
189
+ return Axis2DTitle(self)
190
+
191
+ @property
192
+ def line(self):
193
+ """`Cartesian2DAxisLine`: Axis line style control.
194
+
195
+ Example usage::
196
+
197
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
198
+ >>> # or "plot.axes.x_axis" for field or sketch plots
199
+ >>> axis.line.line_thickness = 0.6
200
+ """
201
+ return Cartesian2DAxisLine(self)
202
+
203
+ @lock()
204
+ def adjust_range_to_nice(self):
205
+ """Rounds the axis range to the nearest major axis increment.
206
+
207
+ This method resets the axis-line label values such that all
208
+ currently displayed label values are set to have the smallest number
209
+ of significant digits possible.
210
+
211
+ Example usage::
212
+
213
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
214
+ >>> # or "plot.axes.x_axis" for field or sketch plots
215
+ >>> axis.adjust_range_to_nice()
216
+ """
217
+ self._view(View.AxisMakeCurrentValuesNice)
218
+
219
+ @property
220
+ def marker_grid_line(self):
221
+ """`MarkerGridLine2D`: Marker line to indicate a particular position along an axis.
222
+
223
+ Example usage::
224
+
225
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
226
+ >>> # or "plot.axes.x_axis" for field or sketch plots
227
+ >>> axis.marker_grid_line.show = True
228
+ >>> axis.marker_grid_line.position = 0.5
229
+ """
230
+ return MarkerGridLine2D(self)
231
+
232
+ def fit_range(self):
233
+ """Set range of axis to variable minimum and maximum.
234
+
235
+ .. note:: If the axis dependency is not `Independent`, then this action
236
+ may also affect the range on another axis.
237
+
238
+ Example usage::
239
+
240
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
241
+ >>> # or "plot.axes.x_axis" for field or sketch plots
242
+ >>> axis.fit_range()
243
+ """
244
+ self._view(View.AxisFit)
245
+
246
+ def fit_range_to_nice(self):
247
+ """Set range of axis to nice values near variable minimum and maximum.
248
+
249
+ This method resets the range to equal the minimum and maximum of the
250
+ data being plotted, but makes the axis values "nice" by setting labels
251
+ to have the smallest number of significant digits possible,
252
+
253
+ .. note:: If the axis dependency is not independent then this method
254
+ may also affect the range on another axis.
255
+
256
+ Example usage::
257
+
258
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
259
+ >>> # or "plot.axes.x_axis" for field or sketch plots
260
+ >>> axis.fit_range_to_nice()
261
+ """
262
+ self._view(View.AxisNiceFit)
263
+
264
+
265
+ class ReversibleAxis(Axis):
266
+ @property
267
+ def reverse(self):
268
+ """`bool`: Reverse the direction of the axis scale.
269
+
270
+ Example usage::
271
+
272
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
273
+ >>> # or "plot.axes.x_axis" for field or sketch plots
274
+ >>> axis.reverse = True
275
+ """
276
+ return self._get_style(bool, sv.ISREVERSED)
277
+
278
+ @reverse.setter
279
+ def reverse(self, value):
280
+ self._set_style(bool(value), sv.ISREVERSED)
281
+
282
+
283
+ class Cartesian2DAxis(Axis):
284
+ @property
285
+ def log_scale(self):
286
+ """`bool`: Use logarithmic scale for this axis.
287
+
288
+ Example usage::
289
+
290
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
291
+ >>> # or "plot.axes.x_axis" for field or sketch plots
292
+ >>> # or "plot.axes.r_axis" for the radial axis in polar plots
293
+ >>> axis.log_scale = True
294
+ """
295
+ return self._get_style(CoordScale, sv.COORDSCALE) is CoordScale.Log
296
+
297
+ @log_scale.setter
298
+ def log_scale(self, value):
299
+ cscale = CoordScale.Log if value else CoordScale.Linear
300
+ self._set_style(cscale, sv.COORDSCALE)
301
+
302
+
303
+ class DataAxis(Axis):
304
+ @property
305
+ def title(self):
306
+ """`str`: Axis title.
307
+
308
+ This is the primary label for the axis and usually includes units::
309
+
310
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
311
+ >>> # or "plot.axes.x_axis" for field or sketch plots
312
+ >>> axis.title.text = 'distance (m)'
313
+ """
314
+ return DataAxis2DTitle(self)
315
+
316
+
317
+ class FieldAxis(DataAxis):
318
+ def fit_range(self, consider_blanking=True):
319
+ """Set range of axis to variable minimum and maximum.
320
+
321
+ .. note:: If the axis dependency is not `Independent`, then this action
322
+ may also affect the range on another axis.
323
+
324
+ Parameters:
325
+ consider_blanking (`Boolean <bool>`, optional): If `True` and
326
+ blanking is enabled, the resulting view excludes blanked cells
327
+ at the edges of the plot. If `False`, then
328
+ the resulting view will ignore blanked cells at the edges of the
329
+ plot. (default: `True`)
330
+
331
+ Example usage::
332
+
333
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
334
+ >>> # or "plot.axes.x_axis" for field or sketch plots
335
+ >>> axis.fit_range()
336
+ """
337
+ self._view(View.AxisFit, consider_blanking)
338
+
339
+ def fit_range_to_nice(self, consider_blanking=True):
340
+ """Set range of axis to nice values near variable minimum and maximum.
341
+
342
+ This method resets the range to equal the minimum and maximum of the
343
+ data being plotted, but makes the axis values "nice" by setting labels
344
+ to have the smallest number of significant digits possible,
345
+
346
+ .. note:: If the axis dependency is not independent then this method
347
+ may also affect the range on another axis.
348
+
349
+ Parameters:
350
+ consider_blanking (`Boolean <bool>`, optional): If `True` and
351
+ blanking is enabled, the resulting view excludes blanked cells
352
+ at the edges of the plot. If `False`, then
353
+ the resulting view will ignore blanked cells at the edges of the
354
+ plot. (default: `True`)
355
+
356
+ Example usage::
357
+
358
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
359
+ >>> # or "plot.axes.x_axis" for field or sketch plots
360
+ >>> axis.fit_range_to_nice()
361
+ """
362
+ self._view(View.AxisNiceFit, consider_blanking)
363
+
364
+ @property
365
+ def variable(self):
366
+ """`Variable`: The `Variable` assigned to this axis.
367
+
368
+ This is the spatial variable associated with this axis
369
+ and is usually one of ``(X, Y, Z)``. Example usage:
370
+
371
+ .. code-block:: python
372
+
373
+ import tecplot as tp
374
+ from tecplot.constant import PlotType
375
+
376
+ fr = tp.active_frame()
377
+ ds = fr.create_dataset('D', ['X', 'Y', 'Z', 'U', 'V'])
378
+ axes = fr.plot(PlotType.Cartesian3D).axes
379
+
380
+ # prints: ('X', 'Y')
381
+ print(axes.x_axis.variable.name, axes.y_axis.variable.name)
382
+
383
+ axes.x_axis.variable = ds.variable('U')
384
+ axes.y_axis.variable = ds.variable('V')
385
+
386
+ # prints: ('U', 'V)
387
+ print(axes.x_axis.variable.name, axes.y_axis.variable.name)
388
+ """
389
+ ds = self.axes.plot.frame.dataset
390
+ return ds.variable(self.variable_index)
391
+
392
+ @variable.setter
393
+ def variable(self, v):
394
+ self.variable_index = v.index
395
+
396
+ @property
397
+ def variable_index(self):
398
+ """`Index` (zero-based): Index of the `Variable` assigned to this axis.
399
+
400
+ Example usage, interchanging the (x, y) axes::
401
+
402
+ >>> v0 = plot.axes.x_axis.variable_index
403
+ >>> v1 = plot.axes.y_axis.variable_index
404
+ >>> plot.axes.x_axis.variable_index = v1
405
+ >>> plot.axes.y_axis.variable_index = v0
406
+ """
407
+ return self._get_style(Index, sv.VARNUM)
408
+
409
+ @variable_index.setter
410
+ def variable_index(self, i):
411
+ self._set_style(Index(i), sv.VARNUM)
412
+
413
+
414
+ class IndexedLineAxis(DataAxis, Cartesian2DAxis, ReversibleAxis):
415
+ def __init__(self, axes, name, index):
416
+ self.index = Index(index)
417
+ super().__init__(axes, name, offset1=self.index)
418
+
419
+ def __eq__(self, that):
420
+ return (isinstance(that, type(self)) and self.index == that.index and
421
+ self.name == that.name and self.axes == that.axes)
422
+
423
+ def __ne__(self, that):
424
+ return not (self == that)
425
+
426
+
427
+ class PolarLineAxis(DataAxis, ReversibleAxis):
428
+ @property
429
+ def line(self):
430
+ """`AxisLine2D`: Axis line style control.
431
+
432
+ Example usage::
433
+
434
+ >>> plot.axes.r_axis.line.line_thickness = 0.6
435
+ >>> plot.axes.theta_axis.line.line_thickness = 0.6
436
+ """
437
+ return AxisLine2D(self)
438
+
439
+ @property
440
+ def origin(self):
441
+ """`float`: Value at the origin of the axis.
442
+
443
+ Example usage::
444
+
445
+ # value at center of plot equal to 10
446
+ >>> plot.axes.r_axis.origin = 10
447
+ # rotate theta axis 45 degrees clockwise
448
+ >>> plot.axes.theta_axis.origin = 45
449
+ """
450
+ return self._get_style(float, sv.VALUEATORIGIN)
451
+
452
+ @origin.setter
453
+ def origin(self, value):
454
+ self._set_style(float(value), sv.VALUEATORIGIN)
455
+
456
+ @property
457
+ def clip_data(self):
458
+ """`bool`: Do not show data outside the axes area.
459
+
460
+ Example usage::
461
+
462
+ >>> plot.axes.clip_data = True
463
+ """
464
+ return self._get_style(bool, sv.CLIPDATA)
465
+
466
+ @clip_data.setter
467
+ def clip_data(self, value):
468
+ self._set_style(bool(value), sv.CLIPDATA)
469
+
470
+
471
+ class Cartesian2DFieldAxis(FieldAxis, Cartesian2DAxis, ReversibleAxis):
472
+ """X or Y axis for 2D field plots.
473
+
474
+ .. code-block:: python
475
+ :emphasize-lines: 18-33
476
+
477
+ from os import path
478
+ import tecplot as tp
479
+ from tecplot.constant import PlotType, AxisMode, AxisTitleMode
480
+
481
+ examples_dir = tp.session.tecplot_examples_directory()
482
+ infile = path.join(examples_dir, 'SimpleData', 'HeatExchanger.plt')
483
+ dataset = tp.data.load_tecplot(infile)
484
+
485
+ frame = tp.active_frame()
486
+ plot = frame.plot(PlotType.Cartesian2D)
487
+
488
+ plot.show_contour = True
489
+
490
+ plot.axes.axis_mode = AxisMode.Independent
491
+ plot.axes.viewport.right = 75
492
+ plot.axes.preserve_scale = False
493
+
494
+ xaxis = plot.axes.x_axis
495
+ xaxis.title.text = 'Longitudinal (m)'
496
+ xaxis.title.title_mode = AxisTitleMode.UseText
497
+ xaxis.min = 3.8
498
+ xaxis.max = 5.3
499
+ xaxis.grid_lines.show = True
500
+ xaxis.grid_lines.draw_last = True
501
+
502
+ yaxis = plot.axes.y_axis
503
+ yaxis.title.text = 'Transverse (m)'
504
+ yaxis.title.title_mode = AxisTitleMode.UseText
505
+ yaxis.min = 2.8
506
+ yaxis.max = 4.3
507
+ yaxis.grid_lines.show = True
508
+ yaxis.minor_grid_lines.show = True
509
+ yaxis.minor_grid_lines.draw_last = True
510
+
511
+ # ensure consistent output between interactive (connected) and batch
512
+ plot.contour(0).levels.reset_to_nice()
513
+
514
+ tp.export.save_png('axis_2d.png',600, supersample=3)
515
+
516
+ .. figure:: /_static/images/axis_2d.png
517
+ :width: 300px
518
+ :figwidth: 300px
519
+ """
520
+
521
+
522
+ class Cartesian3DFieldAxis(FieldAxis):
523
+ """X, Y or Z axis on 3D field plots.
524
+
525
+ .. code-block:: python
526
+ :emphasize-lines: 18,24-36
527
+
528
+ from os import path
529
+ import tecplot as tp
530
+ from tecplot.constant import PlotType, Color, AxisLine3DAssignment
531
+
532
+ examples_dir = tp.session.tecplot_examples_directory()
533
+ infile = path.join(examples_dir, 'SimpleData', 'RainierElevation.lay')
534
+ tp.load_layout(infile)
535
+
536
+ frame = tp.active_frame()
537
+ dataset = frame.dataset
538
+ plot = frame.plot(PlotType.Cartesian3D)
539
+ plot.activate()
540
+
541
+ plot.show_contour = True
542
+
543
+ plot.axes.grid_area.filled = False
544
+
545
+ axes = [plot.axes.x_axis, plot.axes.y_axis, plot.axes.z_axis]
546
+ assignments = [AxisLine3DAssignment.YMinZMax,
547
+ AxisLine3DAssignment.ZMaxXMin,
548
+ AxisLine3DAssignment.XMaxYMin]
549
+
550
+ for ax, asgn in zip(axes, assignments):
551
+ ax.show = True
552
+ ax.grid_lines.show = False
553
+ ax.title.show = False
554
+ ax.line.show = False
555
+ ax.line.edge_assignment = asgn
556
+
557
+ plot.axes.z_axis.grid_lines.show = True
558
+ plot.axes.y_axis.min=-2000
559
+ plot.axes.y_axis.max=1000
560
+ plot.axes.x_axis.min=-9500
561
+ plot.axes.x_axis.max=-7200
562
+ plot.axes.z_axis.min=0
563
+ plot.axes.x_axis.scale_factor=1.9
564
+
565
+ plot.view.width = 7830
566
+ plot.view.alpha = 0
567
+ plot.view.theta = -147.5
568
+ plot.view.psi = 70
569
+ plot.view.position = (1975, 15620, 115930)
570
+
571
+ tp.export.save_png('axis_3d.png', 600, supersample=3)
572
+
573
+ .. figure:: /_static/images/axis_3d.png
574
+ :width: 300px
575
+ :figwidth: 300px
576
+ """
577
+
578
+ @property
579
+ def title(self):
580
+ """`str`: Axis title.
581
+
582
+ This is the primary label for the axis and usually includes units::
583
+
584
+ >>> plot.axes.x_axis.title.text = 'distance (m)'
585
+ """
586
+ return DataAxis3DTitle(self)
587
+
588
+ @property
589
+ def line(self):
590
+ """`AxisLine3D`: Axis line style control.
591
+
592
+ Example usage::
593
+
594
+ >>> plot.axes.x_axis.line.line_thickness = 0.6
595
+ """
596
+ return AxisLine3D(self)
597
+
598
+ @property
599
+ def ticks(self):
600
+ """`Ticks3D`: Axis major and minor ticks style control.
601
+
602
+ Example usage::
603
+
604
+ >>> plot.axes.x_axis.ticks.line_thickness = 0.8
605
+ """
606
+ return Ticks3D(self)
607
+
608
+ @property
609
+ def tick_labels(self):
610
+ """`TickLabels3D`: Axis ticks labels style control.
611
+
612
+ Example usage::
613
+
614
+ >>> plot.axes.x_axis.tick_labels.show = False
615
+ """
616
+ return TickLabels3D(self)
617
+
618
+ @property
619
+ def scale_factor(self):
620
+ """`float`: Factor used for axis scaling.
621
+
622
+ This will automatically scale the other axes if axis mode dependent. Setting the axis mode to independent allows each axis to have their own scale factor::
623
+
624
+ >>> from tecplot.constant import AxisMode
625
+ >>> plot.axes.axis_mode = AxisMode.Independent
626
+ >>> plot.axes.x_axis.scale_factor = 1
627
+ >>> plot.axes.y_axis.scale_factor = 2
628
+ >>> plot.axes.z_axis.scale_factor = 3
629
+ """
630
+ style = session.Style(sv.GLOBALTHREED, sv.AXISSCALEFACT, **self._kw)
631
+ return style._get_style(float, self._sv_name)
632
+
633
+ @scale_factor.setter
634
+ def scale_factor(self, value):
635
+ style = session.Style(sv.GLOBALTHREED, sv.AXISSCALEFACT, **self._kw)
636
+ style._set_style(float(value), self._sv_name)
637
+
638
+ @property
639
+ def grid_lines(self):
640
+ """`GridLines`: Major grid lines style control.
641
+
642
+ Major grid lines are attached to the locations of the major ticks. See
643
+ `minor_grid_lines <Cartesian3DFieldAxis.minor_grid_lines>` for lines
644
+ attached to minor ticks. Example usage::
645
+
646
+ >>> plot.axes.x_axis.grid_lines.show = True
647
+ """
648
+ return GridLines(self)
649
+
650
+ @property
651
+ def minor_grid_lines(self):
652
+ """`MinorGridLines`: Minor grid lines style control.
653
+
654
+ Minor grid lines are attached to the locations of the minor ticks.
655
+ Example usage::
656
+
657
+ >>> plot.axes.x_axis.minor_grid_lines.show = True
658
+ """
659
+ return MinorGridLines(self)
660
+
661
+ @property
662
+ def marker_grid_line(self):
663
+ """`MarkerGridLine`: Marker line to indicate a particular position along an axis.
664
+
665
+ Example usage::
666
+
667
+ >>> plot.axes.x_axis.marker_grid_line.show = True
668
+ >>> plot.axes.x_axis.marker_grid_line.position = 0.5
669
+ """
670
+ return MarkerGridLine(self)
671
+
672
+
673
+ class PolarAngleLineAxis(PolarLineAxis):
674
+ """Theta axis for polar plots.
675
+
676
+ This example manipulates both the theta and radial axes to produce a star
677
+ plot. Custom labels are created for each data point:
678
+
679
+ .. code-block:: python
680
+
681
+ import numpy as np
682
+ import tecplot as tp
683
+ from tecplot.constant import PlotType, ThetaMode, NumberFormat, AxisAlignment
684
+
685
+ np.random.seed(2)
686
+ npoints = 7
687
+ theta = np.linspace(0, npoints, npoints+1)
688
+
689
+ frame = tp.active_frame()
690
+ dataset = frame.create_dataset('Data', ['Magnitude', 'Property'])
691
+
692
+ for i in range(3):
693
+ r = list(np.random.uniform(0.01, 0.99, npoints))
694
+ r.append(r[0])
695
+ zone = dataset.add_ordered_zone('Zone {}'.format(i), (npoints+1,))
696
+ zone.values('Magnitude')[:] = r
697
+ zone.values('Property')[:] = theta
698
+
699
+ plot = frame.plot(PlotType.PolarLine)
700
+ plot.activate()
701
+ plot.delete_linemaps()
702
+
703
+ for i, zone in enumerate(dataset.zones()):
704
+ lmap = plot.add_linemap('Linemap {}'.format(i), zone,
705
+ dataset.variable('Magnitude'),
706
+ dataset.variable('Property'))
707
+ lmap.line.line_thickness = 0.8
708
+
709
+ r_axis = plot.axes.r_axis
710
+ r_axis.max = 1
711
+ r_axis.line.show = False
712
+ r_axis.title.position = 85
713
+ r_axis.line.alignment = AxisAlignment.WithOpposingAxisValue
714
+ r_axis.line.opposing_axis_value = 1
715
+
716
+ theta_axis = plot.axes.theta_axis
717
+ theta_axis.origin = 1
718
+ theta_axis.mode = ThetaMode.Arbitrary
719
+ theta_axis.min = 0
720
+ theta_axis.max = theta.max()
721
+ theta_axis.period = npoints
722
+ theta_axis.ticks.auto_spacing = False
723
+ theta_axis.ticks.spacing = 1
724
+ theta_axis.ticks.minor_num_ticks = 0
725
+ theta_axis.title.show = False
726
+
727
+ theta_labels = theta_axis.tick_labels.format
728
+ theta_labels.format_type = NumberFormat.CustomLabel
729
+ theta_labels.add_custom_labels('A', 'B', 'C', 'D', 'E', 'F', 'G')
730
+ theta_labels.custom_labels_index = 0
731
+
732
+ plot.view.fit()
733
+
734
+ tp.export.save_png('star_plot.png', 600, supersample=3)
735
+
736
+ .. figure:: /_static/images/star_plot.png
737
+ :width: 300px
738
+ :figwidth: 300px
739
+ """
740
+ def __init__(self, axes):
741
+ super().__init__(axes, sv.THETA)
742
+
743
+ @property
744
+ def grid_lines(self):
745
+ """`PolarAngleGridLines`: Theta angle major grid lines.
746
+
747
+ Example usage::
748
+
749
+ >>> plot.axes.theta_axis.grid_lines.show = True
750
+ """
751
+ return PolarAngleGridLines(self)
752
+
753
+ @property
754
+ def minor_grid_lines(self):
755
+ """`PolarAngleMinorGridLines`: Theta angle minor grid lines.
756
+
757
+ Example usage::
758
+
759
+ >>> plot.axes.theta_axis.minor_grid_lines.show = True
760
+ """
761
+ return PolarAngleMinorGridLines(self)
762
+
763
+ @property
764
+ def marker_grid_line(self):
765
+ """`PolarAngleMarkerGridLine`: Theta angle marker grid line.
766
+
767
+ Example usage::
768
+
769
+ >>> plot.axes.theta_axis.marker_grid_line.show = True
770
+ """
771
+ return PolarAngleMarkerGridLine(self)
772
+
773
+ @property
774
+ def mode(self):
775
+ """`ThetaMode`: Units or scale used for the theta axis.
776
+
777
+ Possible values: `ThetaMode.Degrees`, `ThetaMode.Radians`,
778
+ `ThetaMode.Arbitrary`.
779
+
780
+ Example usage::
781
+
782
+ >>> from tecplot.constant import ThetaMode
783
+ >>> plot.axes.theta_axis.mode = ThetaMode.Radians
784
+ """
785
+ return self.axes._get_style(ThetaMode, sv.THETAMODE)
786
+
787
+ @mode.setter
788
+ def mode(self, value):
789
+ self.axes._set_style(ThetaMode(value), sv.THETAMODE)
790
+
791
+ @property
792
+ def period(self):
793
+ """`float`: Number of (min, max) cycles to include in 360 degrees.
794
+
795
+ Example usage::
796
+
797
+ >>> plot.axes.theta_axis.period = 2
798
+ """
799
+ return self.axes._get_style(float, sv.THETAPERIOD)
800
+
801
+ @period.setter
802
+ def period(self, value):
803
+ self.axes._set_style(float(value), sv.THETAPERIOD)
804
+
805
+ @lock()
806
+ def set_range_to_entire_circle(self):
807
+ """Set theta range to entire circle.
808
+
809
+ Example usage::
810
+
811
+ >>> plot.axes.theta_axis.set_range_to_entire_circle()
812
+ """
813
+ self._view(View.AxisResetToEntireCircle)
814
+
815
+
816
+ class RadialLineAxis(PolarLineAxis, Cartesian2DAxis):
817
+ """The R axis for polar plots
818
+
819
+ See the example shown for the `theta axis <PolarAngleLineAxis>`.
820
+ """
821
+ def __init__(self, axes):
822
+ super().__init__(axes, sv.R)
823
+
824
+ @property
825
+ def title(self):
826
+ """`str`: Axis title.
827
+
828
+ This is the primary label for the axis and usually includes units::
829
+
830
+ >>> plot.axes.r_axis.title.text = 'distance (m)'
831
+ """
832
+ return RadialAxisTitle(self)
833
+
834
+ @property
835
+ def line(self):
836
+ """`RadialAxisLine2D`: Radial axis line style control.
837
+
838
+ Example usage::
839
+
840
+ >>> plot.axes.r_axis.line.line_thickness = 0.6
841
+ """
842
+ return RadialAxisLine2D(self)
843
+
844
+ @property
845
+ def ticks(self):
846
+ """`RadialTicks`: Axis major and minor ticks style control.
847
+
848
+ Example usage::
849
+
850
+ >>> plot.axes.r_axis.ticks.line_thickness = 0.8
851
+ """
852
+ return RadialTicks(self)
853
+
854
+ @property
855
+ def tick_labels(self):
856
+ """`RadialTickLabels`: Axis ticks labels style control.
857
+
858
+ Example usage::
859
+
860
+ >>> plot.axes.r_axis.tick_labels.show = False
861
+ """
862
+ return RadialTickLabels(self)
863
+
864
+
865
+ class SketchAxis(Cartesian2DAxis):
866
+ """X or Y axis for sketch plots.
867
+
868
+ .. code-block:: python
869
+ :emphasize-lines: 11-18
870
+
871
+ import tecplot as tp
872
+ from tecplot.constant import PlotType
873
+
874
+ plot = tp.active_frame().plot(PlotType.Sketch)
875
+
876
+ viewport = plot.axes.viewport
877
+ viewport.left = 10
878
+ viewport.right = 90
879
+ viewport.bottom = 10
880
+
881
+ xaxis = plot.axes.x_axis
882
+ xaxis.show = True
883
+ xaxis.min = 0
884
+ xaxis.max = 360
885
+ xaxis.title.text = 'Angle (Degrees)'
886
+
887
+ xaxis.ticks.auto_spacing = False
888
+ xaxis.ticks.spacing = 60
889
+
890
+ tp.export.save_png('axis_sketch.png', 600, supersample=3)
891
+
892
+ .. figure:: /_static/images/axis_sketch.png
893
+ :width: 300px
894
+ :figwidth: 300px
895
+ """
896
+
897
+
898
+ class XYLineAxis(IndexedLineAxis):
899
+ """X or Y axis for line plots.
900
+
901
+ .. code-block:: python
902
+ :emphasize-lines: 18-22,24-25,27-28
903
+
904
+ from os import path
905
+ import tecplot as tp
906
+ from tecplot.constant import PlotType
907
+
908
+ examples_dir = tp.session.tecplot_examples_directory()
909
+ infile = path.join(examples_dir, 'SimpleData', 'Rainfall.dat')
910
+ dataset = tp.data.load_tecplot(infile)
911
+
912
+ plot = tp.active_frame().plot(PlotType.XYLine)
913
+ plot.activate()
914
+
915
+ for i in range(2):
916
+ lmap = plot.linemap(i)
917
+ lmap.show = True
918
+ lmap.line.line_thickness = 0.6
919
+ lmap.y_axis_index = i
920
+
921
+ yax = plot.axes.y_axis(i)
922
+ yax.line.color = lmap.line.color
923
+ yax.title.color = lmap.line.color
924
+ yax.tick_labels.color = lmap.line.color
925
+ yax.line.line_thickness = 0.6
926
+ if i == 0:
927
+ yax.grid_lines.show = True
928
+ yax.grid_lines.color = lmap.line.color
929
+ elif i == 1:
930
+ yax.minor_grid_lines.show = True
931
+ yax.minor_grid_lines.color = lmap.line.color
932
+
933
+ tp.export.save_png('axis_line.png', 600, supersample=3)
934
+
935
+ .. figure:: /_static/images/axis_line.png
936
+ :width: 300px
937
+ :figwidth: 300px
938
+ """
939
+
940
+
941
+ class AxisLine(session.Style):
942
+ def __init__(self, axis):
943
+ self.axis = axis
944
+ super().__init__(axis._sv, sv.AXISLINE, **axis._kw)
945
+
946
+ @property
947
+ def show(self):
948
+ """`bool`: Draw the primary axis line on the plot.
949
+
950
+ Example usage::
951
+
952
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
953
+ >>> # or "plot.axes.x_axis" for field or sketch plots
954
+ >>> axis.line.show = False
955
+ """
956
+ return self._get_style(bool, sv.SHOW)
957
+
958
+ @show.setter
959
+ def show(self, show):
960
+ self._set_style(bool(show), sv.SHOW)
961
+
962
+ @property
963
+ def color(self):
964
+ """`Color`: Color of the axis line.
965
+
966
+ Example usage::
967
+
968
+ >>> from tecplot.constant import Color
969
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
970
+ >>> # or "plot.axes.x_axis" for field or sketch plots
971
+ >>> axis.line.color = Color.Blue
972
+ """
973
+ return self._get_style(Color, sv.COLOR)
974
+
975
+ @color.setter
976
+ def color(self, value):
977
+ self._set_style(Color(value), sv.COLOR)
978
+
979
+ @property
980
+ def line_thickness(self):
981
+ """`float`: Width of the axis line to be drawn.
982
+
983
+ Example usage::
984
+
985
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
986
+ >>> # or "plot.axes.x_axis" for field or sketch plots
987
+ >>> axis.line.line_thickness = 0.5
988
+ """
989
+ return self._get_style(float, sv.LINETHICKNESS)
990
+
991
+ @line_thickness.setter
992
+ def line_thickness(self, value):
993
+ self._set_style(float(value), sv.LINETHICKNESS)
994
+
995
+
996
+ class AxisLine2D(AxisLine):
997
+ """Graduated axis line for 2D plots.
998
+
999
+ Cartesian *(x, y)* plots use an extension of this class
1000
+ (`Cartesian2DAxisLine`). Polar plots use this class directly:
1001
+
1002
+ .. code-block:: python
1003
+
1004
+ import numpy as np
1005
+ import tecplot as tp
1006
+ from tecplot.constant import PlotType, ThetaMode
1007
+
1008
+ npoints = 300
1009
+ r = np.linspace(0, 2000, npoints)
1010
+ theta = np.linspace(0, 10, npoints)
1011
+
1012
+ frame = tp.active_frame()
1013
+ dataset = frame.create_dataset('Data', ['R', 'Theta'])
1014
+ zone = dataset.add_ordered_zone('Zone', (300,))
1015
+ zone.values('R')[:] = r
1016
+ zone.values('Theta')[:] = theta
1017
+ plot = frame.plot(PlotType.PolarLine)
1018
+ plot.activate()
1019
+
1020
+ plot.delete_linemaps()
1021
+ lmap = plot.add_linemap('Linemap', zone, dataset.variable('R'),
1022
+ dataset.variable('Theta'))
1023
+ lmap.line.line_thickness = 0.8
1024
+
1025
+ r_axis = plot.axes.r_axis
1026
+ r_axis.max = np.max(r)
1027
+ r_axis.tick_labels.angle = 45
1028
+ r_axis.tick_labels.font.size *= 2
1029
+
1030
+ theta_axis = plot.axes.theta_axis
1031
+ theta_axis.mode = ThetaMode.Radians
1032
+ theta_axis.tick_labels.font.size *= 2
1033
+
1034
+ plot.view.fit()
1035
+
1036
+ tp.export.save_png('axis_line_2d.png', 600, supersample=3)
1037
+
1038
+ .. figure:: /_static/images/axis_line_2d.png
1039
+ :width: 300px
1040
+ :figwidth: 300px
1041
+ """
1042
+
1043
+ @property
1044
+ def offset(self):
1045
+ """`float` (percent of frame height): Axis line placement with respect to the grid border.
1046
+
1047
+ This is the offset from the grid border-aligned position dictated by
1048
+ properties such as `AxisLine2D.alignment`. The example moves the axis
1049
+ line into the plot by 5% of the frame height::
1050
+
1051
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
1052
+ >>> # or "plot.axes.x_axis" for field or sketch plots
1053
+ >>> axis.line.offset = -5
1054
+ """
1055
+ return self._get_style(float, sv.OFFSET)
1056
+
1057
+ @offset.setter
1058
+ def offset(self, value):
1059
+ self._set_style(float(value), sv.OFFSET)
1060
+
1061
+ @property
1062
+ def opposing_axis_value(self):
1063
+ """`float`: Axis line placement with respect to the opposing axis.
1064
+
1065
+ The axis alignment must be set to `AxisAlignment.WithOpposingAxisValue`
1066
+ to make this property relevant::
1067
+
1068
+ >>> from tecplot.constant import AxisAlignment
1069
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
1070
+ >>> # or "plot.axes.x_axis" for field or sketch plots
1071
+ >>> axis.line.alignment = AxisAlignment.WithOpposingAxisValue
1072
+ >>> axis.line.opposing_axis_value = 0.5
1073
+ """
1074
+ return self._get_style(float, sv.OPPOSINGAXISVALUE)
1075
+
1076
+ @opposing_axis_value.setter
1077
+ def opposing_axis_value(self, value):
1078
+ self._set_style(float(value), sv.OPPOSINGAXISVALUE)
1079
+
1080
+ @property
1081
+ def alignment(self):
1082
+ """`AxisAlignment`: Axis line placement.
1083
+
1084
+ Possible values: `WithViewport`, `WithOpposingAxisValue`,
1085
+ `WithGridMin`, `WithGridMax`, `WithGridAreaTop`, `WithGridAreaBottom`,
1086
+ `WithGridAreaLeft` or `WithGridAreaRight`.
1087
+
1088
+ Not all values will be available for every plot type. Example usage::
1089
+
1090
+ >>> from tecplot.constant import AxisAlignment
1091
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
1092
+ >>> # or "plot.axes.x_axis" for field or sketch plots
1093
+ >>> axis.line.alignment = AxisAlignment.WithGridMin
1094
+ """
1095
+ return self._get_style(AxisAlignment, sv.AXISALIGNMENT)
1096
+
1097
+ @alignment.setter
1098
+ def alignment(self, value):
1099
+ self._set_style(AxisAlignment(value), sv.AXISALIGNMENT)
1100
+
1101
+
1102
+ class Cartesian2DAxisLine(AxisLine2D):
1103
+ """Axis line for 2D field plots.
1104
+
1105
+ .. code-block:: python
1106
+ :emphasize-lines: 19-22
1107
+
1108
+ from os import path
1109
+ import tecplot as tp
1110
+ from tecplot.constant import PlotType, Color, AxisAlignment
1111
+
1112
+ examples_dir = tp.session.tecplot_examples_directory()
1113
+ infile = path.join(examples_dir, 'SimpleData', 'CircularContour.plt')
1114
+ dataset = tp.data.load_tecplot(infile)
1115
+
1116
+ plot = tp.active_frame().plot(PlotType.Cartesian2D)
1117
+ plot.activate()
1118
+
1119
+ plot.show_contour = True
1120
+ plot.contour(0).colormap_name = 'Sequential - Yellow/Green/Blue'
1121
+
1122
+ plot.axes.preserve_scale = True
1123
+ plot.axes.x_axis.fit_range()
1124
+
1125
+ for ax in plot.axes:
1126
+ line = ax.line
1127
+ line.color = Color.DeepRed
1128
+ line.alignment = AxisAlignment.WithOpposingAxisValue
1129
+ line.opposing_axis_value = 0
1130
+ ax.title.position = 85
1131
+
1132
+ plot.contour(0).levels.reset_to_nice()
1133
+
1134
+ tp.export.save_png('axis_line_cartesian2d.png', 600, supersample=3)
1135
+
1136
+ .. figure:: /_static/images/axis_line_cartesian2d.png
1137
+ :width: 300px
1138
+ :figwidth: 300px
1139
+ """
1140
+
1141
+ @property
1142
+ def position(self):
1143
+ """`float`: Axis line placement with respect to the viewport.
1144
+
1145
+ The axis alignment must be set to `AxisAlignment.WithViewport`
1146
+ to make this property relevant::
1147
+
1148
+ >>> from tecplot.constant import AxisAlignment
1149
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
1150
+ >>> # or "plot.axes.x_axis" for field or sketch plots
1151
+ >>> axis.line.alignment = AxisAlignment.WithViewport
1152
+ >>> axis.line.position = 0.5
1153
+ """
1154
+ return self._get_style(float, sv.POSITION)
1155
+
1156
+ @position.setter
1157
+ def position(self, value):
1158
+ self._set_style(float(value), sv.POSITION)
1159
+
1160
+
1161
+ class AxisLine3D(AxisLine):
1162
+ """X, Y or Z axis for 3D field plots.
1163
+
1164
+ This represents the line along which ticks and labels are drawn. The color
1165
+ affects the line itself and the associated tick marks but not labels or
1166
+ axis titles:
1167
+
1168
+ .. code-block:: python
1169
+
1170
+ from os import path
1171
+ import tecplot as tp
1172
+ from tecplot.constant import PlotType, Color
1173
+
1174
+ examples_dir = tp.session.tecplot_examples_directory()
1175
+ infile = path.join(examples_dir, 'SimpleData', 'Sphere.lpk')
1176
+ dataset = tp.load_layout(infile)
1177
+
1178
+ frame = tp.active_frame()
1179
+ plot = frame.plot()
1180
+
1181
+ plot.show_mesh = False
1182
+ plot.axes.grid_area.fill_color = Color.Grey
1183
+
1184
+ for ax in [plot.axes.x_axis, plot.axes.y_axis, plot.axes.z_axis]:
1185
+ ax.show = True
1186
+ ax.grid_lines.show = False
1187
+ ax.line.color = Color.Cyan
1188
+ ax.line.line_thickness = 0.2
1189
+ ax.line.show_on_opposite_edge = True
1190
+
1191
+ plot.view.fit()
1192
+
1193
+ tp.export.save_png('axis_line_3d.png', 600, supersample=3)
1194
+
1195
+ .. figure:: /_static/images/axis_line_3d.png
1196
+ :width: 300px
1197
+ :figwidth: 300px
1198
+ """
1199
+
1200
+ @property
1201
+ def show_on_opposite_edge(self):
1202
+ """`bool`: Draw axis line on opposite edge of axes box.
1203
+
1204
+ Example usage::
1205
+
1206
+ >>> plot.axes.x_axis.line.show_on_opposite_edge = True
1207
+ """
1208
+ return self._get_style(bool, sv.SHOWOPPOSITEEDGE)
1209
+
1210
+ @show_on_opposite_edge.setter
1211
+ def show_on_opposite_edge(self, value):
1212
+ self._set_style(bool(value), sv.SHOWOPPOSITEEDGE)
1213
+
1214
+ @property
1215
+ def edge_assignment(self):
1216
+ """`AxisLine3DAssignment` or `None`: Edge to use when drawing the primary axis line.
1217
+
1218
+ Possible values: `AxisLine3DAssignment.Automatic` (aliased to `None`),
1219
+ `YMinZMin`, `YMaxZMin`, `YMinZMax`, `YMaxZMax`.
1220
+
1221
+ Example usage::
1222
+
1223
+ >>> from tecplot.constant import AxisLine3DAssignment
1224
+ >>> axis.line.edge_assignment = AxisLine3DAssignment.YMinZMin
1225
+ """
1226
+ style = session.Style(**self._kw)
1227
+ auto_reset = style._get_style(bool, sv.THREEDAXIS, sv.EDGEAUTORESET)
1228
+ if auto_reset:
1229
+ return AxisLine3DAssignment.Automatic
1230
+ else:
1231
+ return self._get_style(AxisLine3DAssignment, sv.EDGE)
1232
+
1233
+ @edge_assignment.setter
1234
+ def edge_assignment(self, value):
1235
+ style = session.Style(**self._kw)
1236
+ if value in (None, AxisLine3DAssignment.Automatic):
1237
+ style._set_style(True, sv.THREEDAXIS, sv.EDGEAUTORESET)
1238
+ else:
1239
+ style._set_style(False, sv.THREEDAXIS, sv.EDGEAUTORESET)
1240
+ self._set_style(AxisLine3DAssignment(value), sv.EDGE)
1241
+
1242
+
1243
+ class RadialAxisLine2D(AxisLine2D):
1244
+ """Radial axis line for polar plots.
1245
+
1246
+ .. code-block:: python
1247
+ :emphasize-lines: 26-27
1248
+
1249
+ import numpy as np
1250
+ import tecplot as tp
1251
+ from tecplot.constant import PlotType, Color
1252
+
1253
+ npoints = 300
1254
+ r = np.linspace(0, 2000, npoints)
1255
+ theta = np.linspace(0, 700, npoints)
1256
+
1257
+ frame = tp.active_frame()
1258
+ dataset = frame.create_dataset('Data', ['R', 'Theta'])
1259
+ zone = dataset.add_ordered_zone('Zone', (300,))
1260
+ zone.values('R')[:] = r
1261
+ zone.values('Theta')[:] = theta
1262
+
1263
+ plot = frame.plot(PlotType.PolarLine)
1264
+ plot.activate()
1265
+
1266
+ plot.axes.r_axis.max = np.max(r)
1267
+
1268
+ plot.delete_linemaps()
1269
+ lmap = plot.add_linemap('Linemap', zone, dataset.variable('R'),
1270
+ dataset.variable('Theta'))
1271
+ lmap.line.line_thickness = 0.8
1272
+
1273
+ raxis = plot.axes.r_axis
1274
+ raxis.line.show_both_directions = True
1275
+ raxis.line.show_perpendicular = True
1276
+
1277
+ plot.view.fit()
1278
+
1279
+ tp.export.save_png('axis_line_radial.png', 600, supersample=3)
1280
+
1281
+ .. figure:: /_static/images/axis_line_radial.png
1282
+ :width: 300px
1283
+ :figwidth: 300px
1284
+ """
1285
+
1286
+ @property
1287
+ def show_both_directions(self):
1288
+ """`bool`: Mirror the radial axis 180 degrees from the primary line.
1289
+
1290
+ If `RadialAxisLine2D.show_perpendicular` is `True`, this will mirror
1291
+ that axis line as well resulting in four axis lines, 90 degrees apart.
1292
+ Example usage::
1293
+
1294
+ >>> r_axis.line.show_both_directions = True
1295
+ """
1296
+ return self._get_style(bool, sv.SHOWBOTHDIRECTIONS)
1297
+
1298
+ @show_both_directions.setter
1299
+ def show_both_directions(self, value):
1300
+ self._set_style(bool(value), sv.SHOWBOTHDIRECTIONS)
1301
+
1302
+ @property
1303
+ def show_perpendicular(self):
1304
+ """`bool`: Mirror the radial axis 90 degrees from the primary line.
1305
+
1306
+ Example usage::
1307
+
1308
+ >>> r_axis.line.show_perpendicular = True
1309
+ """
1310
+ return self._get_style(bool, sv.SHOWPERPENDICULAR)
1311
+
1312
+ @show_perpendicular.setter
1313
+ def show_perpendicular(self, value):
1314
+ self._set_style(bool(value), sv.SHOWPERPENDICULAR)
1315
+
1316
+ @property
1317
+ def alignment(self):
1318
+ """`AxisAlignment`: Axis line placement.
1319
+
1320
+ Possible values: `WithOpposingAxisValue`, `WithGridMin`, `WithGridMax`,
1321
+ `WithSpecificAngle`, `WithGridAreaTop`, `WithGridAreaBottom`,
1322
+ `WithGridAreaLeft` or `WithGridAreaRight`.
1323
+
1324
+ Not all values will be available for every plot type. Example usage::
1325
+
1326
+ >>> from tecplot.constant import AxisAlignment
1327
+ >>> plot.r_axis.line.alignment = AxisAlignment.WithOpposingAxisValue
1328
+ >>> plot.r_axis.line.opposing_axis_value = 45
1329
+ """
1330
+ return self._get_style(AxisAlignment, sv.AXISALIGNMENT)
1331
+
1332
+ @alignment.setter
1333
+ def alignment(self, value):
1334
+ self._set_style(AxisAlignment(value), sv.AXISALIGNMENT)
1335
+
1336
+ @property
1337
+ def angle(self):
1338
+ """`float`: Specific angle to place the radial axis line.
1339
+
1340
+ The alignment must be set to `AxisAlignment.WithSpecificAngle`::
1341
+
1342
+ >>> from tecplot.constant import AxisAlignment
1343
+ >>> plot.r_axis.line.alignment = AxisAlignment.WithSpecificAngle
1344
+ >>> plot.r_axis.line.angle = 45
1345
+ """
1346
+ return self._get_style(float, sv.ANGLE)
1347
+
1348
+ @angle.setter
1349
+ def angle(self, value):
1350
+ self._set_style(float(value), sv.ANGLE)