rayoptics.mpl.interactivefigure module

class SelectInfo(artist, info)

Bases: tuple

artist

the artist

info

a dictionary of artist specific details of selection

display_artist_and_event(callback_str, event, artist)[source]
class InteractiveFigure(do_draw_frame=False, do_draw_axes=False, oversize_factor=0.05, aspect='equal', view_bbox=None, do_scale_bounds=False, **kwargs)[source]

Bases: rayoptics.mpl.styledfigure.StyledFigure

Base class for domain specific figures with support for input events

The InteractiveFigure class supplies common implementations for:

  • polyline and polygon 2D graphics
  • selection support for mpl graphic objects
  • mouse/touch event handling
  • interface commands for zooming and panning the display area
do_draw_frame

if True, draw frame around the figure

do_draw_axes

if True, draw coordinate axes for the figure

oversize_factor

what fraction to oversize the view bounding box

aspect

‘equal’ for 1:1 aspect ratio, ‘auto’ for best ratio

artist_filter

an (optional) callable applied in find_artists_at_location(), returns True if rejected

connect_events(action_dict=None)[source]

connect to all the events we need

disconnect_events()[source]

disconnect all the stored connection ids

is_unit_aspect_ratio
refresh(**kwargs)[source]

Call update_data() followed by plot(), return self.

Parameters:kwargs – keyword arguments are passed to update_data
Returns:self (class Figure) so scripting envs will auto display results
update_data(**kwargs)[source]
action_complete()[source]
register_action(*args, **kwargs)[source]
register_pan(on_finished)[source]
register_zoom_box(on_finished)[source]
update_patches(shapes)[source]

loop over the input shapes, fetching their current geometry and attaching it to the corresponding Artist

create_patches(handles)[source]
create_polygon(poly, linewidth=0.5, **kwargs)[source]
create_polyline(poly, linewidth=0.5, hilite_linewidth=2, **kwargs)[source]
create_vertex(vertex, markersize=5, hilite_markersize=7, **kwargs)[source]
update_axis_limits(bbox)[source]
fit_axis_limits()[source]

returns a numpy bounding box that fits the current data

set_view_bbox(bbox)[source]
fit()[source]
zoom(factor)[source]
zoom_in()[source]
zoom_out()[source]
draw_frame(do_draw_frame)[source]
draw_axes(do_draw_axes)[source]
plot()[source]

Draw the actual figure.

find_artists_at_location(event)[source]

Returns a list of shapes in zorder at the event location.

do_shape_action(event, target, event_key)[source]

Execute the target shape’s action for the event_key.

This is the default function that the do_action callable attribute is initialized to.

on_select(event)[source]
display_event(event)[source]
on_press(event)[source]
on_motion(event)[source]
on_release(event)[source]

on release we reset the press data

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, canvas=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, constrained_layout=<UNSET>, constrained_layout_pads=<UNSET>, dpi=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, figheight=<UNSET>, figwidth=<UNSET>, frameon=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linewidth=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, size_inches=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, tight_layout=<UNSET>, transform=<UNSET>, url=<UNSET>, view_bbox=<UNSET>, visible=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Properties:
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None animated: bool canvas: FigureCanvas clip_box: .Bbox clip_on: bool clip_path: Patch or (Path, Transform) or None constrained_layout: bool or dict or None constrained_layout_pads: float, default: :rc:`figure.constrained_layout.w_pad` dpi: float edgecolor: color facecolor: color figheight: float figure: .Figure figwidth: float frameon: bool gid: str in_layout: bool label: object linewidth: number path_effects: .AbstractPathEffect picker: None or bool or float or callable rasterized: bool size_inches: (float, float) or float sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tight_layout: bool or dict with keys “pad”, “w_pad”, “h_pad”, “rect” or None transform: .Transform url: str view_bbox: unknown visible: bool zorder: float
class PanAction(**kwargs)[source]

Bases: object

wrapper class to handle pan action, handing off to Axes

class ZoomBoxAction(fig, **kwargs)[source]

Bases: object

handle zoom box action by using a RectangleSelector widget