qewton.visualization.applications package¶
Module contents¶
Submodules¶
qewton.visualization.applications.base module¶
Base class of the applications, which show a Figure as a connected output.
- class qewton.visualization.applications.base.RenderApplication[source]¶
Bases:
objectBase class for wrapping a Figure in an interactive application: a connected output, in which widgets set the states of controls.
- connected¶
Kinds of control that get a widget (class attribute); the other controls are embedded into the drawn figure.
- Type:
tuple of type
Notes
Subclasses set
connectedand implementrenderer_classes()andcreate().- connected: tuple[type, ...] = ()¶
- classmethod renderer_classes() tuple[type, ...][source]¶
The renderers whose figures the application shows.
- Returns:
Renderer classes.
- Return type:
tuple of type
- classmethod create(figure)[source]¶
Build an application serving figure, with a widget for each connected control.
- Parameters:
figure (Figure) – The figure to serve.
- Returns:
The application.
- Return type:
object
- classmethod check_renderer(figure) None[source]¶
Fail early if the application cannot show figure.
- Parameters:
figure (Figure) – The figure.
- Raises:
TypeError – If the figure’s renderer is none of
renderer_classes().
- classmethod interactive_controls(figure) list[Control][source]¶
The controls of figure that get a widget, in widget order.
- classmethod embedded_controls(figure) list[Control][source]¶
The controls of figure without a widget, embedded into the drawn figure.
- classmethod update(figure, controls: list[Control], states) object[source]¶
Set the states of controls and draw figure with the other controls embedded, as a widget callback does.
- Parameters:
figure (Figure) – The figure.
controls – Its interactive controls.
states – One state per control.
- Returns:
The redrawn backend figure.
- Return type:
object
- qewton.visualization.applications.base.require(application: str, *packages: str) None[source]¶
Fail early if optional packages of an application are missing.
- Parameters:
application – Name of the application, for the message.
*packages – Importable package names.
- Raises:
ImportError – Naming every missing package.
qewton.visualization.applications.dash_app module¶
Interactive Dash application for a Figure.
- class qewton.visualization.applications.dash_app.DashApplication[source]¶
Bases:
RenderApplicationServes a Figure as a Dash app: a slider per SliderAxis and a dropdown per Selector of the figure are connected, i.e. a callback sets their states and draws the figure again; the other controls are embedded into the drawn figure (a TimeAxis as an animation).
See also
- connected: tuple[type, ...] = (<class 'qewton.visualization.axes.SliderAxis'>, <class 'qewton.visualization.axes.Selector'>)¶
- classmethod create(figure)[source]¶
Build a Dash app displaying figure.
- Parameters:
figure (Figure) – The figure to serve.
- Returns:
The application; start it with
app.run().- Return type:
dash.Dash
- Raises:
ImportError – If Dash or Plotly is not installed.
TypeError – If the figure is not drawn by a PlotlyRenderer.
qewton.visualization.applications.widget_app module¶
Interactive notebook application for a Figure, with ipywidgets.
- class qewton.visualization.applications.widget_app.WidgetApplication[source]¶
Bases:
RenderApplicationShows a Figure in a notebook: an interactive Matplotlib canvas (ipympl: zoom, pan, 3D rotation) and a widget per control. A slider sets a SliderAxis, a play button with a slider a TimeAxis, a dropdown a Selector; a change sets the state and redraws the figure in place. Every such control is connected, so nothing is embedded.
Example
>>> WidgetApplication.create(Figure(plot, renderer=MatplotlibRenderer()))
See also
- connected: tuple[type, ...] = (<class 'qewton.visualization.axes.SliderAxis'>, <class 'qewton.visualization.axes.TimeAxis'>, <class 'qewton.visualization.axes.Selector'>)¶
- classmethod create(figure)[source]¶
Build the widgets displaying figure.
- Parameters:
figure (Figure) – The figure to show.
- Returns:
- The canvas, at the figure’s size in a box
scrolling where it is wider than the output, above one row per control; display it as the last expression of a notebook cell.
- Return type:
ipywidgets.VBox
- Raises:
ImportError – If ipywidgets or ipympl is not installed.
TypeError – If the figure is not drawn by a MatplotlibRenderer.