Matplotlib windows manager#
The MatplotWindowsManager
class provides for managing and directly interacting
with Matplotlib windows. By registering these methods with EventsManager
, you can
update plots during run time.
The following example updates window-1
and window-2
during solution initialization
and whenever data is read. During the calculation, it also updates both windows at the end
of every time step.
from ansys.fluent.visualization.matplotlib import Plots
from ansys.fluent.visualization.matplotlib import matplot_windows_manager
plots_session = Plots(session)
#Create xy plot.
plot1 = plots_session.XYPlots["plot-1"]
plot1.surfaces_list = ['symmetry']
plot1.y_axis_function = "temperature"
# Plot XY plot on window-1.
plot1.plot("window-1")
#Create monitor plot.
monitor1 = plots_session.Monitors["monitor-1"]
monitor1.monitor_set_name = "residual"
#Plot monitor on window-2.
monitor1.plot("window-2")
# Create callback that refreshes window-1 and window-2.
def auto_refresh_plot(session_id, event_info):
matplot_windows_manager.refresh_windows(session_id, ["window-1", "window-2"])
#Register this callback with server events.
cb_init_id = session.events_manager.register_callback('InitializedEvent', auto_refresh_plot)
cb_data_read_id = session.events_manager.register_callback('DataReadEvent', auto_refresh_plot)
cb_time_step_ended_id = session.events_manager.register_callback('TimestepEndedEvent', auto_refresh_plot)
- class ansys.fluent.visualization.matplotlib.matplot_windows_manager.MatplotWindowsManager(*args, **kwargs)#
Provides for managing Matplotlib windows.
- animate_windows(session_id='', windows_id=[])#
Animate windows.
- Parameters:
- session_id
str
,optional
Session ID for animating the windows that belong only to this session. The default is
""
, in which case the windows in all sessions are animated.- windows_id
List
[str
],optional
List of IDs for the windows to animate. The default is
[]
, in which case all windows are animated.- Raises
- ——
- NotImplementedError
If not implemented.
- session_id
- Return type:
- close_windows(session_id='', windows_id=[])#
Close windows.
- Parameters:
- Return type:
- open_window(window_id=None)#
Open a new window.
- plot(object, window_id=None)#
Draw a plot.
- Parameters:
- object: PlotDefn
Object to plot.
- window_id
str
,optional
Window ID for the plot. The default is
None
, in which case a unique ID is assigned.
- Raises:
RuntimeError
If the window does not support the object.
- Return type:
- refresh_windows(session_id='', windows_id=[])#
Refresh windows.
- Parameters:
- Return type:
- save_graphic(window_id, format)#
Save a graphic.
- Parameters:
- Raises:
ValueError
If window does not support specified format.
- Return type:
- set_object_for_window(object, window_id)#
Associate a visualization object with a running window instance.
- Parameters:
- object
PlotDefn
Post object to associate with a running window instance.
- window_id
str
Window ID for the association.
- object
- Raises:
RuntimeError
If the window does not support the object.
- Return type: