lstein.lstein.LSteinPanel

class lstein.lstein.LSteinPanel(LSC, theta: float, yticks: Tuple[List[float], List[Any]], panelsize: float = 0.39269908169872414, show_panelbounds: bool = False, show_yticks: bool = True, y_projection_method: Literal['theta', 'y'] = 'theta', ytickkwargs: dict = None, yticklabelkwargs: dict = None, panelboundskwargs: dict = None)[source]

represents a single panel in the LSteinCanvas

  • class defining a panel sitting within a LSteinCanvas

Attributes
  • LSC – see __init__()

  • theta – see __init__()

  • yticks – see __init__()

  • panelsize – see __init__()

  • show_panelbounds – see __init__()

  • show_yticks – see __init__()

  • y_projection_method – see __init__()

  • ytickkwargs – see __init__()

  • yticklabelkwargs – see __init__()

  • panelboundskwargs – see __init__()

Inferred Attributes
  • ylims_data
    • Tuple[float,float]

    • axis limits applied to y

  • ylimrange_data
    • float

    • range of y-values

    • convenience field for relative definitions of plot elements

  • ylims_plot
    • Tuple[float,float]

    • limits used to plot the y-axis

    • sets the frame of reference for plotting

    • set to (0,1) for consistent results

  • ylimrange_data
    • float

    • range of plot values

    • convenience field for relative definitions of plot elements

  • panel_drawn
    • bool

    • flag denoting if the panel has been drawn already

    • to prevent drawing the panel several times when plotting

  • dataseries
    • List[Dict[str,Any]]

    • dataseries to be used for plotting

    • contains
      • x
        • np.ndarray

        • LSteinCanvastransformed (projected) dataseries in cartesian coordinates

        • ready to be plotted

      • y
        • np.ndarray

        • transformed (projected) dataseries in cartesian coordinates

        • ready to be plotted

      • x_cut
        • np.ndarray

        • original dataseries with axis-limits applied

      • y_cut
        • np.ndarray

        • original dataseries with axis-limits applied

    • seriestype
      • Literal[“scatter”,”line”]

      • kind of the series to be displayed

      • used for implementation of plotting functions in backends

    • kwargs
      • kwargs to be passed to the respective plotting function in the backend

Methods
  • get_thetabounds()

  • get_rbounds()

  • set_yticks()

  • draw()

  • apply_axis_limits()

  • project_xy_theta()

  • project_xy_y()

  • project_xy()

  • plot()

  • scatter()

Dependencies
  • matplotlib

  • numpy

  • typing

__init__(LSC, theta: float, yticks: Tuple[List[float], List[Any]], panelsize: float = 0.39269908169872414, show_panelbounds: bool = False, show_yticks: bool = True, y_projection_method: Literal['theta', 'y'] = 'theta', ytickkwargs: dict = None, yticklabelkwargs: dict = None, panelboundskwargs: dict = None)[source]

constructor

  • initializes class

  • computes inferred attributes

Parameters
  • LSC
    • LSteinCanvas

    • parent canvas the panel is associated with

  • theta
    • float

    • theta value the panel is associated with

    • equivalent to 2.5th dimension of the dataset

    • similar to pos in fig.add_subolot(pos)

    • determines where on LSC the panel will be located
      • created panel will be centered around theta with a width of panelsize

  • yticks

    Tuple[List[float],List[Any]] - ticks to draw for the y-axis - also defines axis limits applied to y

    • i.e., bounds of the respective panel

    • yticks[0][0] corresponds to the start of the panel

    • yticks[0][-1] corresponds to the end of the panel

    • yticks[0] will be used as tickpositions

    • yticks[1] will be used as ticklabels

    • yticks[0] has to be sorted in ascending or descending order

    • to invert the y-axis pass yticks[0] in a reverse sorted manner

  • panelsize
    • float, optional

    • (angular) space the created panel will occupy

    • in radians

    • the entire Canvas can allocate (thetaguidelims[1]-thetaguidelims[0])/panelsize evenly distributed, nonoverlapping panels

    • the default is np.pi/8

  • show_panelbounds
    • bool, optional

    • whether to show bounds of the individual panels when rendering

    • the default is False

  • show_yticks
    • bool, optional

    • whether to show ticks and gridlines for y-values

    • the default is True

  • y_projection_method
    • Literal[“theta”,”y”], optional

    • method to use for the projection

    • the default is theta
      • uses LSteinPanel.project_xy_theta()

  • ytickkwargs
    • dict, optional

    • kwargs to pass to ax.plot() when drawing yticks (lines in radial direction)

    • used for styling

    • the default is None
      • will be set to dict(c=plt.rcParams[“grid.color”], ls=plt.rcParams[“grid.linestyle”], lw=plt.rcParams[“grid.linewidth”])

  • yticklabelkwargs
    • dict, optional

    • kwargs to pass to ax.annotate() calls used for defining the ticklabels of the y-axis

    • used for styling

    • pad determines the padding w.r.t. the ticks

    • the default is None
      • will be set to dict(c=plt.rcParams[“axes.labelcolor”], ha=”center”, va=”center”, pad=0.1)

  • panelboundskwargs
    • dict, optional

    • kwargs to pass to ax.plot() when drawing bounds of each panel

    • used for styling

    • the default is None
      • will be set to dict(c=plt.rcParams[“axes.edgecolor”])

Raises

Returns

Methods

__init__(LSC, theta, yticks[, panelsize, ...])

constructor

apply_axis_limits(x, y, **kwargs)

returns x, y and **kwargs after application of axis limits

get_rbounds()

returns panel bounds in radial direction

get_thetabounds()

returns panel location and bounds as angles in radians

get_yticks(theta_lb, theta_ub)

returns yticklabels and location of yticks

plot(x, y[, seriestype])

attaches a dataseries to plot to the panel

project_xy(x, y[, y_projection_method])

returns x and y after projection into the panel

project_xy_theta(x, y)

returns x and y after projection into the panel

project_xy_y(x, y)

returns x and y after projection into the panel

projection_preprocessing_(x, y)

returns x and y after applying transformations preceding all projection methods

apply_axis_limits(x: ndarray, y: ndarray, **kwargs) Tuple[ndarray, ndarray, Dict][source]

returns x, y and **kwargs after application of axis limits

  • method enforce axis limits onto the dataseries
    • only applies out-of-bounds cuts

    • removes any datapoints that are out of bounds in x- or y-direction

Parameters
  • x
    • np.ndarray

    • x-values of the series to be plotted

    • will serve as reference for enforcing self.LSC.xlims_plot

  • y
    • np.ndarray

    • y-values of the series to be plotted

    • will serve as reference for enforcing self.ylims_data

  • **kwargs
    • kwargs ultimately used when plotting y vs x

    • also get modified accordingly i.e.,
      • “c” needs to be set to same size as x_cut and y_cut

      • “s” needs to be set to same size as x_cut and y_cut

      • “alpha” needs to be set to same size as x_cut and y_cut

Raises

Returns
  • x_cut
    • np.ndarray

    • x after applying axis-limit cuts

  • y_cut
    • np.ndarray

    • y after applying axis-limit cuts

  • kwargs
    • Dict

    • **kwargs after applying axis-limit cuts

get_rbounds() Tuple[float, float][source]

returns panel bounds in radial direction

  • method to compute bounds of the panel in radial direction

Parameters

Raises

Returns
  • r_lb
    • float

    • lower bound of the panel in x-direction (radially)

    • located at self.xlimdeadzone*self.LSC.xlimrange_plot

    • corresponds to self.xlims[0]

  • r_ub
    • float

    • upper bound of the panel in x-direction (radially)

    • located at self.LSC.xlimrange_plot

    • corresponds to self.xlims[1]

Comments

get_thetabounds() Tuple[float, float, float][source]

returns panel location and bounds as angles in radians

  • method to compute bounds of the panel as an angle measured from the x-axis counterclockwise (in radians)

Parameters

Raises

Returns
  • theta_lb
    • float

    • lower bound of the panel as an angle in radians

    • corresponds to self.ylims_plot[0] and self.ylims_data[0]

  • theta_ub
    • float

    • upper bound of the panel as an angle in radians

    • corresponds to self.ylims_plot[1] and self.ylims_data[1]

  • theta_offset
    • float

    • offset of the panel w.r.t. the x-axis

    • defines the angular position of the central ray of the panel
      • as an angle measured from the x-axis counterclockwise

      • in radians

get_yticks(theta_lb: float, theta_ub: float) Tuple[List[float], List[Any]][source]

returns yticklabels and location of yticks

  • method to compute angular positions of the y-ticks angles measured from the x-axis counterclockwise (in radians)

Parameters
  • theta_lb
    • float

    • lower bound of the panel as an angle in radians

    • corresponds to self.ylims_plot[0]

  • theta_ub
    • float

    • upper bound of the panel as an angle in radians

    • corresponds to self.ylims_plot[1]

Raises

Returns
  • ytickpos_th
    • List[float]

    • tickpositions angles measured from the x-axis counterclockwise (in radians)

  • yticklabs
    • List[Any]

    • labels assigned to each tick

    • same length as ytickpos_th

plot(x: ndarray, y: ndarray, seriestype: Literal['line', 'scatter'] = 'line', **kwargs)[source]

attaches a dataseries to plot to the panel

  • method to add a series to the panel for plotting

Parameters
  • x
    • np.ndarray

    • x-values of the series

    • has to have same length as y

  • y
    • np.ndarray

    • y-values of the series

    • has to have same length as x

  • seriestpye
    • Literal[“line”,”scatter”], optional

    • which style to use for plotting the series

      “line” – line plot “scatter” – scatter plot

    • the default is “line”

-**kwargs
  • kwargs to pass to ax.plot()

Raises

Returns

project_xy(x: ndarray, y: ndarray, y_projection_method: Literal['theta', 'y'] = 'theta') Tuple[ndarray, ndarray][source]

returns x and y after projection into the panel

  • method to project x and y into the panel using y_projection_method

  • calls upon project_xy_…() based on y_projection_method

  • generally y_projection_method=”theta” is the preferred modus operandi

Parameters
  • x
    • np.ndarray

    • x-values of the series to be projected into the panel

  • y
    • np.ndarray

    • y-values of the series to be projected into the panel

  • y_projection_method
    • Literal[“theta”,”y”], optioal

    • method to use for the projection

    • the default is theta
      • uses self.project_xy_theta()

Raises

Returns
  • x_proj
    • np.ndarray

    • x after projection

  • y_proj
    • np.ndarray

    • y after projection

project_xy_theta(x: ndarray, y: ndarray) Tuple[ndarray, ndarray][source]

returns x and y after projection into the panel

  • method implementing a way to project x and y into the panel

  • operates in theta-space when projecting the series

  • advantages
    • more accurate representation of y-direction

  • downsides
    • more distorsion in x-direction

Parameters
  • x
    • np.ndarray

    • x-values of the series to be projected into the panel

  • y
    • np.ndarray

    • y-values of the series to be projected into the panel

Raises

Returns
  • x_proj
    • np.ndarray

    • x after projection

  • y_proj
    • np.ndarray

    • y after projection

project_xy_y(x: ndarray, y: ndarray) Tuple[ndarray, ndarray, Dict][source]

returns x and y after projection into the panel

  • method implementing a way to project x and y into the panel

  • operates in y-space when projecting the series

  • advantages
    • less distorsion in x-direction

  • downsides
    • can lead to unpredictable offsets in y-direction

Parameters
  • x
    • np.ndarray

    • x-values of the series to be projected into the panel

  • y
    • np.ndarray

    • y-values of the series to be projected into the panel

Raises

Returns
  • x_proj
    • np.ndarray

    • x after projection

  • y_proj
    • np.ndarray

    • y after projection

projection_preprocessing_(x: ndarray, y: ndarray) Tuple[ndarray, ndarray][source]

returns x and y after applying transformations preceding all projection methods

  • method applying preprocessing to x and y

  • applies transformation that precede all projection methods

  • only called from within the projection methods

Parameters
  • x
    • np.ndarray

    • x-values of the series to be projected into the panel

  • y
    • np.ndarray

    • y-values of the series to be projected into the panel

Raises

Returns
  • x_prep
    • np.ndarray

    • x after application of preprocessing

  • y_prep
    • np.ndarray

    • y after application of preprocessing