Advanced pyvista plotting and annotation options #4459
lorenzovecchietti
started this conversation in
Show and tell
Replies: 2 comments
-
In this example I am:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
This script demonstrates how to annotate the point of maximum temperature on a specific object (e.g., "Box2").
from pyvista import Plotter
import ansys.aedt.core as pyaedt
from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter
ipk: pyaedt.Icepak = pyaedt.Icepak(version=2025.1)
plot: ModelPlotter = ipk.post.plot_field(
"Temperature",
"Box2",
show=False,
keep_plot_after_generation=True,
plot_cad_objs=False,
)
plot.plot() # populate pyvista attribute, as `show=False`, nothing will show up
max_temp: dict = ipk.post.get_temperature_extremum(
assignment="Box2", max_min="Max", location="Surface"
)
plot_pv: Plotter = plot.pv
plot_pv.add_point_labels(
[max_temp["Position"]],
[f"{max_temp['Value']:0.2f}"],
always_visible=False,
point_color="red",
font_size=18,
point_size=25,
margin=5,
shape_color="white",
shape_opacity=0.5,
)
plot_pv.view_yx() # point on the surface must be visible from the view
plot_pv.screenshot("test.png") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It is possible to get the pyvista plotter object and modify it further for advanced plotting and annotation.
Beta Was this translation helpful? Give feedback.
All reactions