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/axes.py ADDED
@@ -0,0 +1,881 @@
1
+ from builtins import super
2
+
3
+ from collections import namedtuple
4
+
5
+ from ..tecutil import _tecutil
6
+ from ..constant import *
7
+ from ..exception import *
8
+ from .. import session, tecutil
9
+ from ..tecutil import (inherited_property, flatten_args, lock, lock_attributes,
10
+ sv)
11
+ from .axis import (Cartesian2DFieldAxis, Cartesian3DFieldAxis,
12
+ PolarAngleLineAxis, RadialLineAxis, SketchAxis, XYLineAxis)
13
+ from .grid import (Cartesian2DGridArea, Cartesian3DGridArea, GridArea,
14
+ PreciseGrid)
15
+ from .view import Cartesian2DViewport, PolarViewport, ReadOnlyViewport, Viewport
16
+
17
+
18
+ class Axes(session.Style):
19
+ def __init__(self, plot, *svargs):
20
+ self.plot = plot
21
+ super().__init__(svargs, uniqueid=plot.frame.uid)
22
+
23
+ def __eq__(self, that):
24
+ return isinstance(that, type(self)) and (self.plot == that.plot)
25
+
26
+ def __ne__(self, that):
27
+ return not (self == that)
28
+
29
+ def __iter__(self):
30
+ self._iter_axes = ('x_axis', 'y_axis', 'z_axis', 'r_axis', 'theta_axis')
31
+ self._iter_axis_index = 0
32
+ return self
33
+
34
+ def __next__(self):
35
+ try:
36
+ attr_name = self._iter_axes[self._iter_axis_index]
37
+ self._iter_axis_index += 1
38
+ attr = getattr(self, attr_name, None)
39
+ if attr is not None:
40
+ return attr
41
+ else:
42
+ return next(self)
43
+ except IndexError:
44
+ raise StopIteration
45
+
46
+ def next(self): # if sys.version_info < (3,)
47
+ return self.__next__()
48
+
49
+ @property
50
+ def grid_area(self):
51
+ """`GridArea`: Area bounded by the axes.
52
+
53
+ This controls the background color and border of the axes::
54
+
55
+ >>> from tecplot.constant import Color
56
+ >>> plot.axes.grid_area.fill_color = Color.LightGreen
57
+ """
58
+ return GridArea(self)
59
+
60
+ @property
61
+ def preserve_scale(self):
62
+ """`bool`: Preserve scale (spacing between ticks) on range change.
63
+
64
+ This maintains the axis scaling, i.e. the distance between values along
65
+ the axis. If `False`, the axes length will be preserved when the range
66
+ changes::
67
+
68
+ >>> plot.axes.preserve_scale = False
69
+ >>> # get axis via "plot.axes.x_axis(0)" for line plots
70
+ >>> # or "plot.axes.x_axis" for field or sketch plots
71
+ >>> axis.max = 10 # axis scale is changed (length is preserved)
72
+ """
73
+ return self._get_style(bool, sv.PRESERVEAXISSCALE)
74
+
75
+ @preserve_scale.setter
76
+ def preserve_scale(self, value):
77
+ self._set_style(bool(value), sv.PRESERVEAXISSCALE)
78
+
79
+
80
+ class Axes2D(Axes):
81
+ @property
82
+ def precise_grid(self):
83
+ """`PreciseGrid`: Precise dot grid.
84
+
85
+ This is a set of small dots drawn at the intersection of every minor
86
+ gridline. In line plots, the axis assignments for the first active
87
+ mapping govern the precise dot grid. The precise dot grid option is
88
+ disabled for the 3D Cartesian plots and Line plots when either axis for
89
+ the first active line mapping uses a log scale::
90
+
91
+ >>> plot.axes.precise_grid.show = True
92
+ """
93
+ return PreciseGrid(self)
94
+
95
+
96
+ class CartesianAxes(Axes):
97
+ @property
98
+ def xy_ratio(self):
99
+ """`float`: X:Y axis scaling ratio in percent.
100
+
101
+ This requires the axes to be in dependent mode::
102
+
103
+ >>> from tecplot.constant import AxisMode
104
+ >>> plot.axes.axis_mode = AxisMode.XYDependent
105
+ >>> plot.axes.xy_ratio = 2
106
+ """
107
+ return self._get_style(float, sv.DEPXTOYRATIO)
108
+
109
+ @xy_ratio.setter
110
+ def xy_ratio(self, value):
111
+ self._set_style(float(value), sv.DEPXTOYRATIO)
112
+
113
+
114
+ class Cartesian2DAxes(CartesianAxes):
115
+ @property
116
+ def auto_adjust_ranges(self):
117
+ """`bool`: Automatically adjust axis ranges to nice values.
118
+
119
+ Axes limits will be adjusted to have the smallest number of significant
120
+ digits possible::
121
+
122
+ >>> plot.axes.auto_adjust_ranges = False
123
+ """
124
+ return self._get_style(bool, sv.AUTOADJUSTRANGESTONICEVALUES)
125
+
126
+ @auto_adjust_ranges.setter
127
+ def auto_adjust_ranges(self, value):
128
+ self._set_style(bool(value), sv.AUTOADJUSTRANGESTONICEVALUES)
129
+
130
+ @property
131
+ def axis_mode(self):
132
+ """`AxisMode`: Controls automatic adjustment of axis ranges.
133
+
134
+ Possible values: `Independent`, `XYDependent`.
135
+
136
+ If set to `XYDependent`, then setting the range of one axis
137
+ automatically scales the other indicated axes proportionally to
138
+ maintain the aspect ratio of the plot, effectively zooming in or out.
139
+ If set to `Independent`, adjusting the range of one axis has no effect
140
+ on other axes. Defaults to `Independent` for XY line plots,
141
+ `XYDependent` for 2D Cartesian plots. Example usage::
142
+
143
+ >>> from tecplot.constant import AxisMode
144
+ >>> plot.axes.axis_mode = AxisMode.Independent
145
+ """
146
+ return self._get_style(AxisMode, sv.AXISMODE)
147
+
148
+ @axis_mode.setter
149
+ def axis_mode(self, value):
150
+ self._set_style(AxisMode(value), sv.AXISMODE)
151
+
152
+ @property
153
+ def viewport(self):
154
+ """`Cartesian2DViewport`: Area of the frame used by the plot axes.
155
+
156
+ Example usage::
157
+
158
+ >>> plot.axes.viewport.left = 5
159
+ >>> plot.axes.viewport.right = 95
160
+ >>> plot.axes.viewport.top = 95
161
+ >>> plot.axes.viewport.bottom = 5
162
+ """
163
+ return Cartesian2DViewport(self)
164
+
165
+ @property
166
+ def grid_area(self):
167
+ """`GridArea`: Area bounded by the axes.
168
+
169
+ This controls the background color and border of the axes::
170
+
171
+ >>> from tecplot.constant import Color
172
+ >>> plot.axes.grid_area.fill_color = Color.LightGreen
173
+ """
174
+ return Cartesian2DGridArea(self)
175
+
176
+
177
+ class Cartesian3DAxes(CartesianAxes):
178
+ @property
179
+ def xz_ratio(self):
180
+ """`float`: X:Z axis scaling ratio in percent.
181
+
182
+ This requires the axes to be in dependent mode::
183
+
184
+ >>> from tecplot.constant import AxisMode
185
+ >>> plot.axes.axis_mode = AxisMode.XYZDependent
186
+ >>> plot.axes.xy_ratio = 2
187
+ >>> plot.axes.xz_ratio = 20
188
+ """
189
+ return self._get_style(float, sv.DEPXTOZRATIO)
190
+
191
+ @xz_ratio.setter
192
+ def xz_ratio(self, value):
193
+ self._set_style(float(value), sv.DEPXTOZRATIO)
194
+
195
+ @inherited_property(Cartesian2DAxes)
196
+ def axis_mode(self):
197
+ """`AxisMode`: Scale dependencies along each axis.
198
+
199
+ Possible values: `Independent`, `XYDependent`, `XYZDependent`.
200
+
201
+ If set to `XYDependent` or `XYZDependent`, then setting the range of
202
+ one axis automatically scales the other indicated axes proportionally
203
+ to maintain the aspect ratio of the plot, effectively zooming in or
204
+ out. If set to `Independent`, adjusting the range of one axis has no
205
+ effect on other axes. Defaults to `XYZDependent` for 3D Cartesian
206
+ plots. Both dependent modes allow specifying the axes scaling ratios::
207
+
208
+ >>> from tecplot.constant import AxisMode
209
+ >>> plot.axes.axis_mode = AxisMode.XYZDependent
210
+ >>> plot.axes.xy_ratio = 2
211
+ >>> plot.axes.xz_ratio = 20
212
+ """
213
+
214
+ @property
215
+ def aspect_ratio_limit(self):
216
+ """`float`: Scale limit of the axes aspect ratio.
217
+
218
+ This is the limit above which the axes relative scales will be pegged
219
+ to `aspect_ratio_reset`. The following example will set the aspect
220
+ ratio between scales to 1 if they first exceed a ratio of 10::
221
+
222
+ >>> plot.axes.aspect_ratio_limit = 10
223
+ >>> plot.axes.aspect_ratio_reset = 1
224
+ >>> plot.axes.reset_scale()
225
+ """
226
+ return self._get_style(float, sv.ASPECTRATIOLIMIT)
227
+
228
+ @aspect_ratio_limit.setter
229
+ def aspect_ratio_limit(self, value):
230
+ self._set_style(float(value), sv.ASPECTRATIOLIMIT)
231
+
232
+ @property
233
+ def aspect_ratio_reset(self):
234
+ """`float`: Axes scale aspect ratio used when `aspect_ratio_limit` is exceeded.
235
+
236
+ This is the aspect ratio used to scale the axes when the data's aspect
237
+ ratio exceeds the value set to `aspect_ratio_limit`. The following
238
+ example will set the aspect ratio between scales to 10 if they first
239
+ exceed a ratio of 15::
240
+
241
+ >>> plot.axes.aspect_ratio_limit = 15
242
+ >>> plot.axes.aspect_ratio_reset = 10
243
+ >>> plot.axes.reset_scale()
244
+ """
245
+ return self._get_style(float, sv.ASPECTRATIORESET)
246
+
247
+ @aspect_ratio_reset.setter
248
+ def aspect_ratio_reset(self, value):
249
+ self._set_style(float(value), sv.ASPECTRATIORESET)
250
+
251
+ @property
252
+ def range_aspect_ratio_limit(self):
253
+ """`float`: Range limit of the axes aspect ratio.
254
+
255
+ This is the limit above which the axes' relative ranges will be pegged
256
+ to `range_aspect_ratio_reset`. The following example will set the
257
+ aspect ratio between ranges to 1 if they first exceed a ratio of 10::
258
+
259
+ >>> plot.axes.range_aspect_ratio_limit = 10
260
+ >>> plot.axes.range_aspect_ratio_reset = 1
261
+ >>> plot.axes.reset_range()
262
+ """
263
+ return self._get_style(float, sv.BOXASPECTRATIOLIMIT)
264
+
265
+ @range_aspect_ratio_limit.setter
266
+ def range_aspect_ratio_limit(self, value):
267
+ self._set_style(float(value), sv.BOXASPECTRATIOLIMIT)
268
+
269
+ @property
270
+ def range_aspect_ratio_reset(self):
271
+ """`float`: Axes range aspect ratio used `range_aspect_ratio_limit` is exceeded.
272
+
273
+ This is the aspect ratio used to set the ranges of the axes when the
274
+ axes' aspect ratios exceed the value of `range_aspect_ratio_limit`. The
275
+ following example will set the aspect ratio between ranges to 10 if
276
+ they first exceed a ratio of 15::
277
+
278
+ >>> plot.axes.range_aspect_ratio_limit = 15
279
+ >>> plot.axes.range_aspect_ratio_reset = 10
280
+ >>> plot.axes.reset_range()
281
+ """
282
+ return self._get_style(float, sv.BOXASPECTRATIORESET)
283
+
284
+ @range_aspect_ratio_reset.setter
285
+ def range_aspect_ratio_reset(self, value):
286
+ self._set_style(float(value), sv.BOXASPECTRATIORESET)
287
+
288
+ @property
289
+ def auto_edge_assignment(self):
290
+ """`bool`: Enable automatically choosing which edges to label.
291
+
292
+ Example usage::
293
+
294
+ >>> plot.axes.auto_edge_assignment = True
295
+ """
296
+ return self._get_style(bool, sv.EDGEAUTORESET)
297
+
298
+ @auto_edge_assignment.setter
299
+ def auto_edge_assignment(self, value):
300
+ self._set_style(bool(value), sv.EDGEAUTORESET)
301
+
302
+ @property
303
+ def viewport(self):
304
+ """`ReadOnlyViewport`: Area of the frame used by the plot axes.
305
+
306
+ Example usage::
307
+
308
+ >>> print(plot.axes.viewport.bottom)
309
+ 5
310
+ """
311
+ return ReadOnlyViewport(self)
312
+
313
+ @lock()
314
+ def reset_scale(self):
315
+ """Recalculate and set the scale factors for each axis.
316
+
317
+ Aspect ratio limits are taken into account::
318
+
319
+ >>> plot.axes.reset_scale()
320
+ """
321
+ with self.plot.frame.activated():
322
+ if not _tecutil.Reset3DScaleFactors():
323
+ raise TecplotSystemError()
324
+
325
+ @lock()
326
+ def reset_range(self):
327
+ """Recalculate and set the ranges for each axis.
328
+
329
+ Example usage::
330
+
331
+ >>> plot.axes.reset_range()
332
+ """
333
+ with self.plot.frame.activated():
334
+ if not _tecutil.Reset3DAxes():
335
+ raise TecplotSystemError()
336
+
337
+ @lock()
338
+ def reset_origin(self, location=OriginResetLocation.DataCenter):
339
+ """Set the origin to the specified location.
340
+
341
+ Parameters:
342
+ location (`OriginResetLocation`, optional): Either the center of
343
+ the data with `OriginResetLocation.DataCenter` (default) or the
344
+ center of the viewport with `OriginResetLocation.ViewCenter`.
345
+
346
+ Example usage::
347
+
348
+ >>> from tecplot.constant import OriginResetLocation
349
+ >>> plot.axes.reset_origin(OriginResetLocation.ViewCenter)
350
+ """
351
+ with self.plot.frame.activated():
352
+ with tecutil.ArgList() as arglist:
353
+ arglist[sv.ORIGINRESETLOCATION] = OriginResetLocation(location)
354
+ if not _tecutil.Reset3DOriginX(arglist):
355
+ raise TecplotSystemError()
356
+
357
+ @property
358
+ def grid_area(self):
359
+ """`Cartesian3DGridArea`: Area of the viewport used by the axes.
360
+
361
+ Example usage::
362
+
363
+ >>> plot.axes.grid_area.fill_color = Color.LightGreen
364
+ """
365
+ return Cartesian3DGridArea(self)
366
+
367
+ @property
368
+ def padding(self):
369
+ """`float`: Margin of axis padding around data in percent of data extent.
370
+
371
+ Example usage::
372
+
373
+ >>> plot.axes.padding = 5
374
+ """
375
+ style = session.Style(**self._kw)
376
+ return style._get_style(float, sv.GLOBALTHREED, sv.AXISBOXPADDING)
377
+
378
+ @padding.setter
379
+ def padding(self, value):
380
+ style = session.Style(**self._kw)
381
+ style._set_style(float(value), sv.GLOBALTHREED, sv.AXISBOXPADDING)
382
+
383
+ @property
384
+ def orientation_axis(self):
385
+ """`OrientationAxis`: Get the 3D Orientation Axes.
386
+
387
+ Example usage::
388
+
389
+ >>> # Hide the orientation axes
390
+ >>> plot.axes.orientation_axis.show = False
391
+ """
392
+ return OrientationAxis(self)
393
+
394
+
395
+ class SketchAxes(Cartesian2DAxes, Axes2D):
396
+ """(X, Y) axes style control for sketch plots.
397
+
398
+ Sketch plots have cartesian *x* and *y* axes which can be adjusted using
399
+ the viewport:
400
+
401
+ .. code-block:: python
402
+ :emphasize-lines: 7-13
403
+
404
+ import tecplot as tp
405
+ from tecplot.constant import PlotType
406
+
407
+ frame = tp.active_frame()
408
+ plot = frame.plot(PlotType.Sketch)
409
+
410
+ plot.axes.x_axis.show = True
411
+ plot.axes.y_axis.show = True
412
+
413
+ plot.axes.viewport.left = 10
414
+ plot.axes.viewport.right = 90
415
+ plot.axes.viewport.bottom = 10
416
+ plot.axes.viewport.top = 90
417
+
418
+ tp.export.save_png('axes_sketch.png', 600, supersample=3)
419
+
420
+ .. figure:: /_static/images/axes_sketch.png
421
+ :width: 300px
422
+ :figwidth: 300px
423
+ """
424
+ def __init__(self, plot):
425
+ super().__init__(plot, sv.SKETCHAXIS)
426
+
427
+ @property
428
+ def x_axis(self):
429
+ """`SketchAxis`: X-axis style control.
430
+
431
+ Example usage::
432
+
433
+ >>> plot.axes.x_axis.show = True
434
+ """
435
+ return SketchAxis(self, sv.X)
436
+
437
+ @property
438
+ def y_axis(self):
439
+ """`SketchAxis`: Y-axis style control.
440
+
441
+ Example usage::
442
+
443
+ >>> plot.axes.y_axis.show = True
444
+ """
445
+ return SketchAxis(self, sv.Y)
446
+
447
+
448
+ class Cartesian2DFieldAxes(Cartesian2DAxes, Axes2D):
449
+ """(X, Y) axes style control for 2D field plots.
450
+
451
+ .. code-block:: python
452
+ :emphasize-lines: 15-17
453
+
454
+ from os import path
455
+ import tecplot as tp
456
+ from tecplot.constant import PlotType
457
+
458
+ examples_dir = tp.session.tecplot_examples_directory()
459
+ infile = path.join(examples_dir, 'SimpleData', 'HeatExchanger.plt')
460
+ dataset = tp.data.load_tecplot(infile)
461
+
462
+ frame = tp.active_frame()
463
+ plot = frame.plot(PlotType.Cartesian2D)
464
+
465
+ plot.show_shade = False
466
+ plot.show_contour = True
467
+
468
+ plot.axes.auto_adjust_ranges = True
469
+ plot.axes.precise_grid.show = True
470
+ plot.axes.precise_grid.size = 0.05
471
+
472
+ plot.view.fit()
473
+
474
+ # ensure consistent output between interactive (connected) and batch
475
+ plot.contour(0).levels.reset_to_nice()
476
+
477
+ tp.export.save_png('axes_2d.png', 600, supersample=3)
478
+
479
+ .. figure:: /_static/images/axes_2d.png
480
+ :width: 300px
481
+ :figwidth: 300px
482
+ """
483
+ def __init__(self, plot):
484
+ super().__init__(plot, sv.TWODAXIS)
485
+
486
+ @property
487
+ def x_axis(self):
488
+ """`Cartesian2DFieldAxis`: X-axis style control.
489
+
490
+ Example usage::
491
+
492
+ >>> plot.axes.x_axis.show = False
493
+ """
494
+ return Cartesian2DFieldAxis(self, sv.X)
495
+
496
+ @property
497
+ def y_axis(self):
498
+ """`Cartesian2DFieldAxis`: Y-axis style control.
499
+
500
+ Example usage::
501
+
502
+ >>> plot.axes.y_axis.show = False
503
+ """
504
+ return Cartesian2DFieldAxis(self, sv.Y)
505
+
506
+
507
+ class Cartesian3DFieldAxes(Cartesian3DAxes):
508
+ """(X, Y, Z) axes style control for 3D field plots.
509
+
510
+ .. code-block:: python
511
+ :emphasize-lines: 12-16
512
+
513
+ from os import path
514
+ import tecplot as tp
515
+ from tecplot.constant import PlotType, Color
516
+
517
+ examples_dir = tp.session.tecplot_examples_directory()
518
+ infile = path.join(examples_dir, 'SimpleData', 'Sphere.lpk')
519
+ dataset = tp.load_layout(infile)
520
+
521
+ frame = tp.active_frame()
522
+ plot = frame.plot()
523
+
524
+ plot.axes.x_axis.show = True
525
+ plot.axes.y_axis.show = True
526
+ plot.axes.z_axis.show = True
527
+ plot.axes.grid_area.fill_color = Color.SkyBlue
528
+ plot.axes.padding = 20
529
+
530
+ plot.view.fit()
531
+
532
+ tp.export.save_png('axes_3d.png', 600, supersample=3)
533
+
534
+ .. figure:: /_static/images/axes_3d.png
535
+ :width: 300px
536
+ :figwidth: 300px
537
+ """
538
+ def __init__(self, plot):
539
+ super().__init__(plot, sv.THREEDAXIS)
540
+
541
+ @property
542
+ def x_axis(self):
543
+ """`Cartesian3DFieldAxis`: X-axis style control.
544
+
545
+ Example usage::
546
+
547
+ >>> plot.axes.x_axis.show = True
548
+ """
549
+ return Cartesian3DFieldAxis(self, sv.X)
550
+
551
+ @property
552
+ def y_axis(self):
553
+ """`Cartesian3DFieldAxis`: Y-axis style control.
554
+
555
+ Example usage::
556
+
557
+ >>> plot.axes.y_axis.show = True
558
+ """
559
+ return Cartesian3DFieldAxis(self, sv.Y)
560
+
561
+ @property
562
+ def z_axis(self):
563
+ """`Cartesian3DFieldAxis`: Z-axis style control.
564
+
565
+ Example usage::
566
+
567
+ >>> plot.axes.z_axis.show = True
568
+ """
569
+ return Cartesian3DFieldAxis(self, sv.Z)
570
+
571
+
572
+ class PolarLineAxes(Axes2D):
573
+ """(R, Theta) axes style control for polar plots.
574
+
575
+ Example usage:
576
+
577
+ .. code-block:: python
578
+ :emphasize-lines: 19-20
579
+
580
+ import numpy as np
581
+ import tecplot as tp
582
+ from tecplot.constant import PlotType, ThetaMode
583
+
584
+ frame = tp.active_frame()
585
+
586
+ npoints = 300
587
+ r = np.linspace(0, 2000, npoints)
588
+ theta = np.linspace(0, 10, npoints)
589
+
590
+ dataset = frame.create_dataset('Data', ['R', 'Theta'])
591
+ zone = dataset.add_ordered_zone('Zone', (300,))
592
+ zone.values('R')[:] = r
593
+ zone.values('Theta')[:] = theta
594
+
595
+ plot = frame.plot(PlotType.PolarLine)
596
+ plot.activate()
597
+
598
+ plot.axes.r_axis.max = np.max(r)
599
+ plot.axes.theta_axis.mode = ThetaMode.Radians
600
+
601
+ plot.delete_linemaps()
602
+ lmap = plot.add_linemap('Linemap', zone, dataset.variable('R'),
603
+ dataset.variable('Theta'))
604
+ lmap.line.line_thickness = 0.8
605
+
606
+ plot.view.fit()
607
+
608
+ tp.export.save_png('axes_polar.png', 600, supersample=3)
609
+
610
+ .. figure:: /_static/images/axes_polar.png
611
+ :width: 300px
612
+ :figwidth: 300px
613
+ """
614
+ def __init__(self, plot):
615
+ super().__init__(plot, sv.POLARAXIS)
616
+
617
+ @property
618
+ def r_axis(self):
619
+ """`RadialLineAxis`: Radial axis style control.
620
+
621
+ Example usage::
622
+
623
+ >>> plot.axes.r_axis.title.text = 'R (meters)'
624
+ """
625
+ return RadialLineAxis(self)
626
+
627
+ @property
628
+ def theta_axis(self):
629
+ """`PolarAngleLineAxis`: Polar-angle axis style control.
630
+
631
+ Example usage::
632
+
633
+ >>> plot.axes.theta_axis.title.text = 'Theta (radians)'
634
+ """
635
+ return PolarAngleLineAxis(self)
636
+
637
+ @property
638
+ def viewport(self):
639
+ """`PolarViewport`: Area of the frame used by the plot axes outside the grid area.
640
+
641
+ Example usage::
642
+
643
+ >>> from tecplot.constant import Color
644
+ >>> plot.axes.viewport.fill_color = Color.LightGreen
645
+ """
646
+ return PolarViewport(self)
647
+
648
+
649
+ class XYLineAxes(Cartesian2DAxes, Axes2D):
650
+ """(X, Y) axes style control for line plots.
651
+
652
+ The ``axes`` property of a `XYLinePlot` allows access to the several ``x``
653
+ and ``y`` axes by index. Linemaps can use any of the five such axes. In
654
+ this example, we create two sets of data with different scales and the
655
+ second y-axis is used on the right side of the plot:
656
+
657
+ .. code-block:: python
658
+ :emphasize-lines: 32,44
659
+
660
+ import numpy as np
661
+ import tecplot as tp
662
+ from tecplot.constant import PlotType, Color
663
+
664
+ frame = tp.active_frame()
665
+
666
+ npoints = 100
667
+ x = np.linspace(-10,10,npoints)
668
+ t = x**2
669
+ p = 0.1 * np.sin(x)
670
+
671
+ dataset = frame.create_dataset('data', ['Position (m)', 'Temperature (K)',
672
+ 'Pressure (Pa)'])
673
+ zone = dataset.add_ordered_zone('zone', (100,))
674
+ zone.values('Position (m)')[:] = x
675
+ zone.values('Temperature (K)')[:] = t
676
+ zone.values('Pressure (Pa)')[:] = p
677
+
678
+ plot = frame.plot(PlotType.XYLine)
679
+ plot.activate()
680
+ plot.delete_linemaps()
681
+
682
+ temp = plot.add_linemap('temp', zone, dataset.variable('Position (m)'),
683
+ dataset.variable('Temperature (K)'))
684
+ press = plot.add_linemap('press', zone, dataset.variable('Position (m)'),
685
+ dataset.variable('Pressure (Pa)'))
686
+
687
+ # Color the line and the y-axis for temperature
688
+ temp.line.color = Color.RedOrange
689
+ temp.line.line_thickness = 0.8
690
+
691
+ ax = plot.axes.y_axis(0)
692
+ ax.line.color = temp.line.color
693
+ ax.tick_labels.color = temp.line.color
694
+ ax.title.color = temp.line.color
695
+
696
+ # set pressure linemap to second x-axis
697
+ press.y_axis_index = 1
698
+
699
+ # Color the line and the y-axis for pressure
700
+ press.line.color = Color.Chartreuse
701
+ press.line.line_thickness = 0.8
702
+
703
+ ax = plot.axes.y_axis(1)
704
+ ax.line.color = press.line.color
705
+ ax.tick_labels.color = press.line.color
706
+ ax.title.color = press.line.color
707
+
708
+ tp.export.save_png('axes_line.png', 600, supersample=3)
709
+
710
+ .. figure:: /_static/images/axes_line.png
711
+ :width: 300px
712
+ :figwidth: 300px
713
+ """
714
+ def __init__(self, plot):
715
+ super().__init__(plot, sv.XYLINEAXIS)
716
+
717
+ def __iter__(self):
718
+ self._iter_axes = ['x_axis', 'y_axis'] * 5
719
+ self._iter_axis_index = 0
720
+ return self
721
+
722
+ def __next__(self):
723
+ try:
724
+ attr_name = self._iter_axes[self._iter_axis_index]
725
+ index = self._iter_axis_index // 2
726
+ self._iter_axis_index += 1
727
+ return getattr(self, attr_name)(index)
728
+ except IndexError:
729
+ raise StopIteration
730
+
731
+ def x_axis(self, index):
732
+ """`XYLineAxis`: X-axis style control.
733
+
734
+ There are five x-axes for each `XYLinePlot`, indexed from 0 to 4
735
+ inclusive::
736
+
737
+ >>> plot.axes.x_axis(0).show = True
738
+ """
739
+ return XYLineAxis(self, sv.X, index)
740
+
741
+ def y_axis(self, index):
742
+ """`XYLineAxis`: Y-axis style control.
743
+
744
+ There are five y-axes for each `XYLinePlot`, indexed from 0 to 4
745
+ inclusive::
746
+
747
+ >>> plot.axes.y_axis(0).show = True
748
+ """
749
+ return XYLineAxis(self, sv.Y, index)
750
+
751
+
752
+ class OrientationAxis(session.Style):
753
+ """The orientation axis for 3D Field plots.
754
+
755
+ This is the small (x, y, z) reference axis object which can moved, resized
756
+ and modified using this class.
757
+
758
+ By default, all 3D plots show the 3D orientation axis in the upper right
759
+ of the frame. It can be repositioned by setting `position` as shown
760
+ below:
761
+
762
+ .. code-block:: python
763
+ :emphasize-lines: 12-13
764
+
765
+ from os import path
766
+ import tecplot as tp
767
+ from tecplot.constant import Color
768
+
769
+ examples_dir = tp.session.tecplot_examples_directory()
770
+ infile = path.join(examples_dir, 'SimpleData', 'Sphere.lpk')
771
+ dataset = tp.load_layout(infile)
772
+
773
+ frame = tp.active_frame()
774
+ plot = frame.plot()
775
+
776
+ plot.axes.orientation_axis.position = 15, 15
777
+ plot.axes.orientation_axis.color = Color.BrightCyan
778
+
779
+ plot.axes.reset_range()
780
+ plot.view.fit()
781
+
782
+ tp.export.save_png('axes_orientation.png', 600, supersample=3)
783
+
784
+ .. figure:: /_static/images/axes_orientation.png
785
+ :width: 300px
786
+ :figwidth: 300px
787
+ """
788
+ def __init__(self, axes):
789
+ self.axes = axes
790
+ super().__init__(axes._sv, sv.FRAMEAXIS, **axes._kw)
791
+
792
+ @property
793
+ def show(self):
794
+ """`bool`: Enable drawing of the orientation axis.
795
+
796
+ Example usage::
797
+
798
+ >>> plot.axes.orientation_axis.show = False
799
+ """
800
+ return self._get_style(bool, sv.SHOW)
801
+
802
+ @show.setter
803
+ def show(self, value):
804
+ self._set_style(bool(value), sv.SHOW)
805
+
806
+ @property
807
+ def size(self):
808
+ """`float`: Size of the orientation axis as a percentage of frame size (0-100).
809
+
810
+ Example usage::
811
+
812
+ >>> plot.axes.orientation_axis.size = 4.0
813
+ """
814
+ return self._get_style(float, sv.SIZE)
815
+
816
+ @size.setter
817
+ def size(self, value):
818
+ self._set_style(float(value), sv.SIZE)
819
+
820
+ @property
821
+ def line_thickness(self):
822
+ """`float`: Line thickness used when drawing the orientation axis as a percentage of frame height.
823
+
824
+ Example usage::
825
+
826
+ >>> plot.axes.orientation_axis.line_thickness = 0.8
827
+ """
828
+ return self._get_style(float, sv.LINETHICKNESS)
829
+
830
+ @line_thickness.setter
831
+ def line_thickness(self, value):
832
+ self._set_style(float(value), sv.LINETHICKNESS)
833
+
834
+ @property
835
+ def color(self):
836
+ """`Color`: `Color` of the orientation axes.
837
+
838
+ Example usage::
839
+
840
+ >>> from tecplot.constant import Color
841
+ >>> plot.axes.orientation_axis.color = Color.Cyan
842
+ """
843
+ return self._get_style(Color, sv.COLOR)
844
+
845
+ @color.setter
846
+ def color(self, value):
847
+ self._set_style(Color(value), sv.COLOR)
848
+
849
+ _Position = namedtuple('Position', ['x', 'y'])
850
+
851
+ @property
852
+ def position(self):
853
+ """`tuple`: ``(x, y)`` position of the orientation axis.
854
+
855
+ The position is in percent from the lower-left corner of the viewport::
856
+
857
+ >>> plot.axes.orientation_axis.position = (15, 15)
858
+ """
859
+ x = self._get_style(float, sv.XYPOS, sv.X)
860
+ y = self._get_style(float, sv.XYPOS, sv.Y)
861
+ return OrientationAxis._Position(x, y)
862
+
863
+ @position.setter
864
+ def position(self, *pos):
865
+ pos = OrientationAxis._Position(*flatten_args(*pos))
866
+ self._set_style(float(pos.x), sv.XYPOS, sv.X)
867
+ self._set_style(float(pos.y), sv.XYPOS, sv.Y)
868
+
869
+ @property
870
+ def show_variable_name(self):
871
+ """`bool`: Use variable names instead of 'X', 'Y' and 'Z'.
872
+
873
+ Example usage::
874
+
875
+ >>> plot.axes.orientation_axis.show_variable_name = True
876
+ """
877
+ return self._get_style(bool, sv.SHOWVARIABLENAME)
878
+
879
+ @show_variable_name.setter
880
+ def show_variable_name(self, value):
881
+ self._set_style(bool(value), sv.SHOWVARIABLENAME)