Matplot Windows Manager#
This class manages MatplotLib windows and provides methods to directly interact with them. By registering these methods to EventsManager, plots can be updated during run time.
The following example will update window-1 and window-2 during solution initialization and whenever data is read. Also during calculation it will update both windows at 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 which 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)#
Class for matplot windows manager.
- animate_windows(session_id='', windows_id=[])#
Animate windows.
- Parameters
- Raises
NotImplementedError
If not implemented.
- Return type
- close_windows(session_id='', windows_id=[])#
Close windows.
- Parameters
- Return type
- open_window(window_id=None)#
Open new window.
- Parameters
- window_id
str
,optional
Id for new window. If not specified unique id is used.
- window_id
- Returns
str
Window id.
- Return type
- plot(object, window_id=None)#
Draw plot.
- Parameters
- object: PlotDefn
Object to plot.
- window_id
str
,optional
Window id for plot. If not specified unique id is used.
- Raises
RuntimeError
If window does not support object.
- Return type
- refresh_windows(session_id='', windows_id=[])#
Refresh windows.
- Parameters
- Return type
- save_graphic(window_id, format)#
Save graphics.
- Parameters
- Raises
ValueError
If window does not support specified format.
- Return type
- set_object_for_window(object, window_id)#
Associate visualization object with running window instance.
- Parameters
- object
PlotDefn
Post object to associate with window.
- window_id
str
Window id to associate.
- object
- Raises
RuntimeError
If window does not support object.
- Return type