Drawing¶
- class sofia_redux.visualization.display.drawing.Drawing(**kwargs)[source]¶
Bases:
objectClass to hold an individual matplotlib artist.
Attributes Summary
matplotlib.collections.PolyCollection : Matplotlib artist.
str : Axes containing the drawing artist.
str : Matplotlib color for artist.
str : Reference data ID.
dict : Plot fields associated with drawing axes.
str : High-level model name for the drawing.
str : Classification category for the drawing.
str : Label for the drawing.
str : Marker associated with the artist.
str : Mid-level model name for the drawing.
uuid.UUID : Model ID for the drawing.
Pane : Display pane containing the drawing.
str : Current state of the drawing.
bool : Flag to indicate an update is required.
dict : New updates to apply to the drawing.
bool : Visibility state for the artist
Methods Summary
apply_updates(updates)Apply updates to the current drawing.
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 the animated state for the artist.
Get the
artistattribute.get_axes()Get the
axesattribute.Get the
colorattribute.Get the
data_idattribute.Get the
fieldsattribute.Get the
high_modelattribute.get_kind()Get the
kindattribute.Get the
labelattribute.Get the linestyle associated with the artist.
Get the
markerattribute.Get the
mid_modelattribute.Get the
model_idattribute.get_pane()Get the
paneattribute.Get the
stateattribute.Get the
updateattribute.Get the
updatesattribute.Get the
visibleattribute.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
artistattribute.set_axes(axes)Set the
axesattribute.set_color(color)Set the
colorattribute.set_data([data, axis, update])Set data for the current artist.
set_data_id(data_id)Set the
data_idattribute.set_fields(fields)Set the
fieldsattribute.set_high_model(high_model)Set the
high_modelattribute.set_kind(kind)Set the
kindattribute.set_label(label)Set the
labelattribute.set_marker(marker)Set the
markerattribute.set_mid_model(mid_model)Set the
mid_modelattribute.set_model_id(model_id)Set the
model_idattribute.set_pane(pane)Set the
paneattribute.set_state(state)Set the
stateattribute.set_update(update)Set the
updateattribute.set_updates(updates)Update the
updatesattribute.set_visible(visible)Set the
visibleattribute.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.
- 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_high_model()[source]¶
Get the
high_modelattribute.
- 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
strictis 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.
- 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
dataandaxisinputs.
- set_high_model(high_model)[source]¶
Set the
high_modelattribute.
- 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.