pymor.discretizers.builtin.gui.jupyter package

This module provides plotting support inside the Jupyter notebook.

To use these routines you first have to execute

%matplotlib notebook

inside the given notebook.

Submodules

logging module


class pymor.discretizers.builtin.gui.jupyter.logging.LogViewer(out, accordion=None)[source]

Bases: logging.Handler

Methods

LogViewer

close, emit

Handler

acquire, createLock, flush, format, get_name, handle, handleError, release, set_name, setFormatter, setLevel

Filterer

addFilter, filter, removeFilter

Attributes

LogViewer

empty, out

Handler

name

__repr__()[source]

Return repr(self).

close()[source]

Tidy up any resources used by the handler.

This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.


class pymor.discretizers.builtin.gui.jupyter.logging.LoggingRedirector[source]

Bases: object

Methods

LoggingRedirector

start, stop

matplotlib module


class pymor.discretizers.builtin.gui.jupyter.matplotlib.MPLPlotBase(U, grid, codim, legend, bounding_box=None, separate_colorbars=False, columns=2, separate_plots=False, separate_axes=False)[source]

Bases: object


pymor.discretizers.builtin.gui.jupyter.matplotlib.visualize_matplotlib_1d(grid, U, codim=1, title=None, legend=None, separate_plots=True, separate_axes=False, columns=2)[source]

Visualize scalar data associated to a one-dimensional Grid as a plot.

The grid’s ReferenceElement must be the line. The data can either be attached to the subintervals or vertices of the grid.

Parameters

grid

The underlying Grid.

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as an animation in a single axes object or a series of axes, depending on the separate_axes switch. It is also possible to provide a tuple of VectorArrays, in which case several plots are made into one or multiple figures, depending on the separate_plots switch. The lengths of all arrays have to agree.

codim

The codimension of the entities the data in U is attached to (either 0 or 1).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_plots

If True, use multiple figures to visualize multiple VectorArrays.

separate_axes

If True, use separate axes for each figure instead of an Animation.

column

Number of columns the subplots are organized in.


pymor.discretizers.builtin.gui.jupyter.matplotlib.visualize_patch(grid, U, bounding_box=[0, 0], [1, 1], codim=2, title=None, legend=None, separate_colorbars=False, rescale_colorbars=False, columns=2)[source]

Visualize scalar data associated to a two-dimensional Grid as a patch plot.

The grid’s ReferenceElement must be the triangle or square. The data can either be attached to the faces or vertices of the grid.

Parameters

grid

The underlying Grid.

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case a subplot is created for each entry of the tuple. The lengths of all arrays have to agree.

bounding_box

A bounding box in which the grid is contained.

codim

The codimension of the entities the data in U is attached to (either 0 or 2).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_colorbars

If True, use separate colorbars for each subplot.

rescale_colorbars

If True, rescale colorbars to data in each frame.

columns

The number of columns in the visualizer GUI in case multiple plots are displayed at the same time.

threejs module


class pymor.discretizers.builtin.gui.jupyter.threejs.ColorBarRenderer(*args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.VBox

Methods

ColorBarRenderer

freeze_camera, goto

DOMWidget

add_class, remove_class

Widget

add_traits, close, close_all, get_manager_state, get_state, get_view_spec, handle_comm_opened, hold_sync, notify_change, on_displayed, on_msg, on_widget_constructed, open, send, send_state, set_state, __del__

HasTraits

class_own_trait_events, class_own_traits, class_trait_names, class_traits, has_trait, hold_trait_notifications, observe, on_trait_change, set_trait, setup_instance, trait_events, trait_metadata, trait_names, traits, unobserve, unobserve_all

Attributes

Box

box_style, children

DOMWidget

layout

Widget

comm, keys, model_id, widget_types, widgets

LoggingHasTraits

log

HasTraits

cross_validation_lock


class pymor.discretizers.builtin.gui.jupyter.threejs.Renderer(*args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.VBox

Methods

Renderer

freeze_camera, goto

DOMWidget

add_class, remove_class

Widget

add_traits, close, close_all, get_manager_state, get_state, get_view_spec, handle_comm_opened, hold_sync, notify_change, on_displayed, on_msg, on_widget_constructed, open, send, send_state, set_state, __del__

HasTraits

class_own_trait_events, class_own_traits, class_trait_names, class_traits, has_trait, hold_trait_notifications, observe, on_trait_change, set_trait, setup_instance, trait_events, trait_metadata, trait_names, traits, unobserve, unobserve_all

Attributes

Box

box_style, children

DOMWidget

layout

Widget

comm, keys, model_id, widget_types, widgets

LoggingHasTraits

log

HasTraits

cross_validation_lock


class pymor.discretizers.builtin.gui.jupyter.threejs.ThreeJSPlot(*args, **kwargs)[source]

Bases: ipywidgets.widgets.widget_box.VBox

Methods

ThreeJSPlot

finish_loading

DOMWidget

add_class, remove_class

Widget

add_traits, close, close_all, get_manager_state, get_state, get_view_spec, handle_comm_opened, hold_sync, notify_change, on_displayed, on_msg, on_widget_constructed, open, send, send_state, set_state, __del__

HasTraits

class_own_trait_events, class_own_traits, class_trait_names, class_traits, has_trait, hold_trait_notifications, observe, on_trait_change, set_trait, setup_instance, trait_events, trait_metadata, trait_names, traits, unobserve, unobserve_all

Attributes

Box

box_style, children

DOMWidget

layout

Widget

comm, keys, model_id, widget_types, widgets

LoggingHasTraits

log

HasTraits

cross_validation_lock


pymor.discretizers.builtin.gui.jupyter.threejs.visualize_py3js(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None, legend=None, separate_colorbars=False, rescale_colorbars=False, columns=2, color_map=<matplotlib.colors.ListedColormap object>)[source]

Generate a pythreejs Plot and associated controls for scalar data associated to a two-dimensional Grid.

The grid’s ReferenceElement must be the triangle or square. The data can either be attached to the faces or vertices of the grid.

Parameters

grid

The underlying Grid.

U

VectorArray of the data to visualize. If len(U) 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case a subplot is created for each entry of the tuple. The lengths of all arrays have to agree.

bounding_box

A bounding box in which the grid is contained.

codim

The codimension of the entities the data in U is attached to (either 0 or 2).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_colorbars

If True, use separate colorbars for each subplot.

rescale_colorbars

If True, rescale colorbars to data in each frame.

columns

The number of columns in the visualizer GUI in case multiple plots are displayed at the same time.

color_map

a Matplotlib Colormap object