Drawing

class sofia_redux.visualization.display.drawing.Drawing(**kwargs)[source]

Bases: object

Class to hold an individual matplotlib artist.

Attributes Summary

artist

matplotlib.collections.PolyCollection : Matplotlib artist.

axes

str : Axes containing the drawing artist.

color

str : Matplotlib color for artist.

data_id

str : Reference data ID.

fields

dict : Plot fields associated with drawing axes.

high_model

str : High-level model name for the drawing.

kind

str : Classification category for the drawing.

label

str : Label for the drawing.

marker

str : Marker associated with the artist.

mid_model

str : Mid-level model name for the drawing.

model_id

uuid.UUID : Model ID for the drawing.

pane

Pane : Display pane containing the drawing.

state

str : Current state of the drawing.

update

bool : Flag to indicate an update is required.

updates

dict : New updates to apply to the drawing.

visible

bool : Visibility state for the artist

Methods Summary

apply_updates(updates)

Apply updates to the current drawing.

clear_updates()

Clear any existing updates.

convert_to_line(drawstyle, marker)

Convert a scatter plot to a line plot.

convert_to_scatter(line_artist, marker)

Convert a line plot to a scatter plot.

get_animated()

Get the animated state for the artist.

get_artist()

Get the artist attribute.

get_axes()

Get the axes attribute.

get_color()

Get the color attribute.

get_data_id()

Get the data_id attribute.

get_fields()

Get the fields attribute.

get_high_model()

Get the high_model attribute.

get_kind()

Get the kind attribute.

get_label()

Get the label attribute.

get_linestyle()

Get the linestyle associated with the artist.

get_marker()

Get the marker attribute.

get_mid_model()

Get the mid_model attribute.

get_model_id()

Get the model_id attribute.

get_pane()

Get the pane attribute.

get_state()

Get the state attribute.

get_update()

Get the update attribute.

get_updates()

Get the updates attribute.

get_visible()

Get the visible attribute.

in_pane(pane[, alt])

Check if current drawing is in specified pane.

match_axes(axes)

Match axes.

match_data_id(data_id)

Match data IDs.

match_fields(fields)

Match fields.

match_high_model(name)

Match high models.

match_id(model_id)

Match model IDs.

match_kind(kind)

Match drawing kinds.

match_mid_model(name)

Match mid models.

match_pane(pane)

Match panes.

match_text(artist)

Match text.

matches(other[, strict])

Check if this drawing matches another.

populate_properties(kwargs)

Set standard properties for the artist

remove()

Remove an artist from the plot and from this drawing.

set_animated(state)

Set the animated state for the artist.

set_artist(artist)

Set the artist attribute.

set_axes(axes)

Set the axes attribute.

set_color(color)

Set the color attribute.

set_data([data, axis, update])

Set data for the current artist.

set_data_id(data_id)

Set the data_id attribute.

set_fields(fields)

Set the fields attribute.

set_high_model(high_model)

Set the high_model attribute.

set_kind(kind)

Set the kind attribute.

set_label(label)

Set the label attribute.

set_marker(marker)

Set the marker attribute.

set_mid_model(mid_model)

Set the mid_model attribute.

set_model_id(model_id)

Set the model_id attribute.

set_pane(pane)

Set the pane attribute.

set_state(state)

Set the state attribute.

set_update(update)

Set the update attribute.

set_updates(updates)

Update the updates attribute.

set_visible(visible)

Set the visible attribute.

update_line_fields(update)

Update line fields.

update_options(other[, kind])

Update plot options from another drawing.

Attributes Documentation

artist

matplotlib.collections.PolyCollection : Matplotlib artist.

Matplotlib artist appropriate to the data type, such as a rectangle for the border or a line for the data plot.

axes

str : Axes containing the drawing artist.

May be ‘primary’ or ‘alternate’.

color

str : Matplotlib color for artist.

data_id

str : Reference data ID.

Labels reference data lines, e.g. with wavelength values.

fields

dict : Plot fields associated with drawing axes.

Typical values are: ‘wavepos’, ‘spectral_flux’, ‘spectral_error’, ‘transmission’, ‘response’.

high_model

str : High-level model name for the drawing.

kind

str : Classification category for the drawing.

Available kinds:
  • line

  • border

  • error

  • crosshair

  • guide

  • cursor

  • fit_line

  • fit_center

  • text

  • reference

  • patch

label

str : Label for the drawing.

marker

str : Marker associated with the artist.

mid_model

str : Mid-level model name for the drawing.

model_id

uuid.UUID : Model ID for the drawing.

Unique id associated with a single input file.

pane

Pane : Display pane containing the drawing.

state

str : Current state of the drawing.

Set to ‘new’ on initialization.

update

bool : Flag to indicate an update is required.

updates

dict : New updates to apply to the drawing.

Keys represent the axis being changed and the values are lists of values to update.

visible

bool : Visibility state for the artist

Methods Documentation

apply_updates(updates)[source]

Apply updates to the current drawing.

Parameters:
updatesdict

Updates to apply.

clear_updates() None[source]

Clear any existing updates.

convert_to_line(drawstyle: str, marker: str) None[source]

Convert a scatter plot to a line plot.

Parameters:
scatter_artistPathCollection

The scatter plot artist to replace.

drawstylestr

The line drawing style for the new line plot. Should be ‘line’ or ‘step’.

markerstr

The marker symbol to use in the plot. If None, the default ‘o’ symbol is used.

Returns:
line_artistLine2D

The new line plot artist.

static convert_to_scatter(line_artist: Line2D, marker: str) PathCollection[source]

Convert a line plot to a scatter plot.

Parameters:
line_artistLine2D

The line artist to replace.

markerstr

The marker symbol to use in the plot. If None, the default ‘o’ symbol is used.

Returns:
scatter_artistPathCollection

The new scatter plot artist.

get_animated()[source]

Get the animated state for the artist.

get_artist()[source]

Get the artist attribute.

get_axes()[source]

Get the axes attribute.

get_color()[source]

Get the color attribute.

get_data_id()[source]

Get the data_id attribute.

get_fields()[source]

Get the fields attribute.

get_high_model()[source]

Get the high_model attribute.

get_kind()[source]

Get the kind attribute.

get_label()[source]

Get the label attribute.

get_linestyle()[source]

Get the linestyle associated with the artist.

get_marker()[source]

Get the marker attribute.

get_mid_model()[source]

Get the mid_model attribute.

get_model_id()[source]

Get the model_id attribute.

get_pane()[source]

Get the pane attribute.

get_state()[source]

Get the state attribute.

get_update()[source]

Get the update attribute.

get_updates()[source]

Get the updates attribute.

get_visible()[source]

Get the visible attribute.

in_pane(pane, alt=False) bool[source]

Check if current drawing is in specified pane.

Parameters:
panePane

Pane instance to check.

altbool, optional

If set, alternate axes are checked as well as the primary.

Returns:
bool

True if artist is in specified pane; False otherwise.

match_axes(axes)[source]

Match axes.

If either value is ‘any’, True is always returned.

Parameters:
axesstr

Axes to compare to this drawing’s axes attribute.

Returns:
successbool

True if fields match; False otherwise.

match_data_id(data_id)[source]

Match data IDs.

Parameters:
data_idstr

Data ID to compare to this drawing’s data_id attribute.

Returns:
successbool

True if data IDs match; False otherwise.

match_fields(fields)[source]

Match fields.

Parameters:
fieldslist or dict

Fields to compare to this drawing’s fields attribute.

Returns:
successbool

True if fields match; False otherwise.

match_high_model(name)[source]

Match high models.

Parameters:
namestr

Model name to compare to this drawing’s high_model attribute.

Returns:
successbool

True if model IDs match; False otherwise.

match_id(model_id: UUID) bool[source]

Match model IDs.

Parameters:
model_iduuid.UUID

Model ID to compare to this drawing’s model_id attribute.

Returns:
successbool

True if model IDs match; False otherwise.

match_kind(kind)[source]

Match drawing kinds.

Parameters:
kindstr

Kind to compare to this drawing’s kind attribute.

Returns:
successbool

True if kinds match; False otherwise.

match_mid_model(name)[source]

Match mid models.

Parameters:
namestr

Model name to compare to this drawing’s mid_model attribute.

For multi-order spectra, mid-model is formatted as
<order>.<aperture>. Both must match.
Returns:
successbool

True if model IDs match; False otherwise.

match_pane(pane)[source]

Match panes.

Parameters:
panePane

Pane to compare to this drawing’s pane attribute.

Returns:
successbool

True if panes match; False otherwise.

match_text(artist)[source]

Match text.

Parameters:
artistmatplotlib.Artist

Artist containing text values, retrievable via get_text().

Returns:
successbool

True if text values match; False otherwise.

matches(other, strict=False)[source]

Check if this drawing matches another.

Required attributes for matching are model_id, kind, mid_model, and data_id. If strict is set, pane, fields, and axes must additionally match.

Parameters:
otherDrawing

The other drawing to compare against.

strictbool

If True, drawings must match exactly.

Returns:
matchbool

True if drawings match; False otherwise.

populate_properties(kwargs: Dict)[source]

Set standard properties for the artist

Parameters:
kwargsdict

Keys may be: ‘visible’, ‘color’, ‘marker’, ‘alpha’, ‘linestyle’. Values must be appropriate for the Matplotlib artist for the associated property.

remove()[source]

Remove an artist from the plot and from this drawing.

set_animated(state)[source]

Set the animated state for the artist.

set_artist(artist)[source]

Set the artist attribute.

set_axes(axes)[source]

Set the axes attribute.

set_color(color)[source]

Set the color attribute.

set_data(data=None, axis: str | None = None, update: Optional = None)[source]

Set data for the current artist.

Parameters:
dataarray-like, optional

If provided, may be used to directly set the data for the artist.

axis{‘x’, ‘y’}, optional

Specifies the axis to set data for.

updatedict, optional

Keys may be ‘x_data’, ‘y_data’, ‘artist’. If ‘x_data’ or ‘y_data’ are provided, they override the data and axis inputs.

set_data_id(data_id)[source]

Set the data_id attribute.

set_fields(fields)[source]

Set the fields attribute.

set_high_model(high_model)[source]

Set the high_model attribute.

set_kind(kind)[source]

Set the kind attribute.

set_label(label)[source]

Set the label attribute.

set_marker(marker)[source]

Set the marker attribute.

set_mid_model(mid_model)[source]

Set the mid_model attribute.

set_model_id(model_id)[source]

Set the model_id attribute.

set_pane(pane)[source]

Set the pane attribute.

set_state(state)[source]

Set the state attribute.

set_update(update)[source]

Set the update attribute.

set_updates(updates)[source]

Update the updates attribute.

set_visible(visible)[source]

Set the visible attribute.

update_line_fields(update)[source]

Update line fields.

Currently has no effect.

update_options(other, kind='default') bool[source]

Update plot options from another drawing.

Parameters:
otherDrawing

Drawing to copy updates from.

kindstr

Kind of drawing to apply updates to. If default, all available updates are applied.

Returns:
successbool

True if an update is found and applied; False otherwise.