lstein.lstein.LSteinCanvas¶
- class lstein.lstein.LSteinCanvas(thetaticks: Tuple[List[float], List[Any]] | List[float], xticks: Tuple[List[float], List[Any]] | List[float], yticks: Tuple[List[float], List[Any]] | List[float], thetaguidelims: Tuple[float, float] = None, thetaplotlims: Tuple[float, float] = None, xlimdeadzone: float = 0.3, panelsize: float = 0.39269908169872414, thetalabel: str = None, xlabel: str = None, ylabel: str = None, thetaarrowpos_th: float = None, ylabpos_th: float = None, thetatickkwargs: dict = None, thetaticklabelkwargs: dict = None, thetalabelkwargs: dict = None, xtickkwargs: dict = None, xticklabelkwargs: dict = None, xlabelkwargs: dict = None, ylabelkwargs: dict = None)[source]¶
main canvas to draw LSteinPanels into
class containing the canvas to draw `LSteinPanel`s into
analogous to matplotlib.figure.Figure
parent to LSteinPanel
- Attributes
thetaticks – see __init__()
xticks – see __init__()
yticks – see __init__()
thetaguidelims – see __init__()
thetaplotlims – see __init__()
xlimdeadzone – see __init__()
panelsize – see __init__()
thetalabel – see __init__()
xlabel – see __init__()
ylabel – see __init__()
thetaarrowpos_th – see __init__()
ylabpos_th – see __init__()
thetatickkwargs – see __init__()
thetaticklabelkwargs – see __init__()
thetalabelkwargs – see __init__()
xtickkwargs – see __init__()
xticklabelkwargs – see __init__()
labelkwargs – see __init__()
- Inferred Attributes
- thetalims
Tuple[float,float]
- axis limits applied to theta
i.e., in azimuthal direction
thetalims[0] corresponds to the lowest value of theta that will be plotted
thetalims[1] corresponds to the highest value of theta that will be plotted
- xlims_data
Tuple[float,float]
- axis limits applied to x
i.e., in radial direction
xlims_data[0] corresponds to the value plotted at the end of xlimdeadzone
xlims_data[1] corresponds to the value plotted at the outer bound of the LStein plot
- xlimrange_data
float
range of x-values
convenience field for relative definitions of plot elements
- xlims_plot
Tuple[float,float]
limits used to plot the x-axis
sets the frame of reference for plotting
- set to (0,1) for consistent results
i.e., in radial direction
xlims_plot[0] corresponds to xlims_data[0]
xlims_plot[1] corresponds to xlims_data[1]
- xlimrange_data
float
range of plot values
convenience field for relative definitions of plot elements
- Panels
List[LSteinPanel]
collection of panels associated with LSteinCanvas instance
- canvas_drawn
bool
flag denoting if the canvas has been drawn alrady
to prevent drawing the canvas several times when plotting
- Methods
compute_xaxis()
compute_thetaaxis()
compute_ylabel()
add_panel()
get_thetas()
get_panel()
plot()
- Dependencies
matplotlib
numpy
typing
- __init__(thetaticks: Tuple[List[float], List[Any]] | List[float], xticks: Tuple[List[float], List[Any]] | List[float], yticks: Tuple[List[float], List[Any]] | List[float], thetaguidelims: Tuple[float, float] = None, thetaplotlims: Tuple[float, float] = None, xlimdeadzone: float = 0.3, panelsize: float = 0.39269908169872414, thetalabel: str = None, xlabel: str = None, ylabel: str = None, thetaarrowpos_th: float = None, ylabpos_th: float = None, thetatickkwargs: dict = None, thetaticklabelkwargs: dict = None, thetalabelkwargs: dict = None, xtickkwargs: dict = None, xticklabelkwargs: dict = None, xlabelkwargs: dict = None, ylabelkwargs: dict = None)[source]¶
constructor
initializes class
computes inferred attributes
- Parameters
- thetaticks
Tuple[List[float],List[Any]], List[float]
ticks to draw for the theta-axis (angular positioning)
- also defines axis limits applied to theta
i.e., in azimuthal direction
np.min(thetaticks[0]) corresponds to the lowest value of theta that will be plotted
np.max(thetaticks[0]) corresponds to the highest value of theta that will be plotted
- if List[float]
will use thetaticks as labels as well
- if Tuple[List[float],List[Any]]
will use thetaticks[1] as ticklabels
- xticks
Tuple[List[float],List[Any]], List[float]
ticks (circles) to draw for the x-axis
- also defines axis limits applied to x
i.e., in radial direction
xticks[0][0] corresponds to the end of xlimdeadzone
xticks[0][-1] corresponds to the value plotted at the outer bound of the LStein plot
xticks[0] has to be sorted in ascending or descending order
to invert the x-axis pass xticks[0] in a reverse sorted manner
- if List[float]
will use xticks as labels as well
- if Tuple[List[float],List[Any]]
will use xticks[1] as ticklabels
- yticks
Tuple[List[float],List[Any]], List[float]
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] has to be sorted in ascending or descending order
to invert the y-axis pass yticks[0] in a reverse sorted manner
- if List[float]
will use yticks as ticklabels as well
- if Tuple[List[float],List[Any]]
will use yticks[1] as ticklabels
- thetaguidelims
Tuple[float,float], optional
- range to be spanned by the entire plot guides
only affects the background grid
in radians
- the default is None
will be set to (0,np.pi)
an semi-circle will be plotted
- thetaplotlims
Tuple[float,float], optional
range to be populated by with theta-panels
- sets the reference point for thetaticks
np.min(thetaticks[0]) will be plotted at thetaplotlims[0]
np.max(thetaticks[0]) will be plotted at thetaplotlims[1]
in radians
- the default is None
will be set to thetaguidelims with extra padding of panelsize/2
- xlimdeadzone
float, optional
amount of space to leave empty in the center of the plot
provided as a fraction of the entire plot-radius
- used to
reduce projection effects at small radii
have space for labelling
- the default is 0.3
30% of the radial direction is left empty
- panelsize
- float, optional
global default of (angular) space any created panel will occupy
in rthetalims
can be overridden by calling self.add_panel()
the entire canvas can allocate (thetaguidelims[1]-thetaguidelims[0])/panelsize evenly distributed, nonoverlapping panels
the default is np.pi/8
- thetalabel
str, optional
label of the theta-axis
- the default is None
will be set to “”
- xlabel
str, optional
label of the x-axis
- the default is None
will be set to “”
- ylabel
str, optional
label of the y-axis
- the default is None
will be set to “”
- th_arrowpos_th
float, optional
position of the arrow indicating the theta-axis
given in units of theta
- the default is None
will be set to np.mean(thetaticks[0])
- ylabpos_th
float, optional
position of ylabel
given in units of theta
- the default is None
will be set to thetaticks[0][0]
at the first tick of the theta axis
- thetatickkwargs
dict, optional
kwargs to pass to ax.plot() when drawing the theta ticks
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”])
- thetaticklabelkwargs
dict, optional
kwargs to pass to ax.annotate() calls used for defining the ticklabels of the theta-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.2)
- thetalabelkwargs
dict, optional
kwargs to pass to ax.annotate() call used for defining the axis label of the theta-axis
used for styling
- the default is None
will be set to dict(c=plt.rcParams[“axes.labelcolor”], ha=”center”, va=”center”)
- xtickkwargs
dict, optional
kwargs to pass to ax.plot() when drawing xticks (circles)
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”])
- xticklabelkwargs
dict, optional
kwargs to pass to ax.annotate() calls used for defining the ticklabels of the x-axis
used for styling
- the default is None
will be set to dict(c=plt.rcParams[“axes.labelcolor”], textcoords=”offset fontsize”, xytext=(-1,-1))
- xlabelkwargs
dict, optional
kwargs to pass to ax.annotate() call used for defining the axis label of the x-axis
used for styling
- the default is None
will be set to dict(c=plt.rcParams[“axes.labelcolor”], textcoords=”offset fontsize”, xytext=(-2,-2))
- ylabelkwargs
dict, optional
kwargs to pass to ax.annotate() call used for defining the axis label 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”], pad=0.15)
Raises
Returns
Methods
__init__(thetaticks, xticks, yticks[, ...])constructor
add_panel(theta[, yticks, panelsize, ...])returns created LSteinPanel
computes and returns various elements necessary for adding the theta-axis (azimuthal) to the canvas
computes and returns various elements necessary for adding the x-axis to the canvas
computes and returns coordinates of for positioning the ylabel
get_panel(theta)returns a panel associated with theta
returns theta of all currently added panels
plot(theta, X, Y[, seriestype, ...])adds all series defined in theta, X, Y to respective panels for plotting
reset()resets all plotting-related flags in LSteinCanvas
- add_panel(theta: float, yticks: Tuple[List[float], List[Any]] | List[float] = None, panelsize: float = None, show_panelbounds: bool = False, show_yticks: bool = True, y_projection_method: Literal['y', 'theta'] = 'theta', ytickkwargs: dict = None, yticklabelkwargs: dict = None, panelboundskwargs: dict = None) LSteinPanel[source]¶
returns created LSteinPanel
method to add a LSteinPanel to the canvas
similar to matplotlibs fig.add_subplot()
- Parameters
- theta
float
theta value the panel is associated with
equivalent to 2.5th dimension of the dataset
- determines where on the canvas the panel will be located
created panel will be centered around theta
- yticks
Tuple[List[float],List[Any]], List[float], optional - ticks to draw for the y-axis - also defines axis limits applied to y
i.e., bounds of the respective panel
np.min(yticks[0]) corresponds to the start of the panel
np.max(yticks[0]) corresponds to the end of the panel
- if List[float]
will use yticks as ticklabels as well
- if Tuple[List[float],List[Any]]
will use yticks[1] as ticklabels
overrides self.yticks
- the default is None
will fall back to self.yticks
- 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
overrides self.panelsize
- the default is None
will fall back to self.panelsize
- 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_mode
Literal[“theta”,”y”], optioal
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
- LSP
LSteinPanel
created panel
- compute_thetaaxis() Tuple[Any][source]¶
computes and returns various elements necessary for adding the theta-axis (azimuthal) to the canvas
Parameters
Raises
- Returns
- thetatickpos_xi
np.ndarray
inner bound of theta ticks
in cartesian coordinates
- thetatickpos_yi
np.ndarray
inner bound of theta ticks
in cartesian coordinates
- thetatickpos_xo
np.ndarray
outer bound of theta ticks
in cartesian coordinates
- thetatickpos_yo
np.ndarray
outer bound of theta ticks
in cartesian coordinates
- thetaticklabelpos_x
np.ndarray
x-values of position of theta ticklabels
- thetaticklabelpos_y
np.ndarray
y-values of position of theta ticklabels
- thetaticklabs
np.ndarray
text to be displayed as x-ticklabels
- thlabpos_x
float
x-value to place theta-label at
- thlabpos_y
float
y-value to place theta-label at
- x_arrow
float
x-value to place indicator arrow at
- x_arrow
float
y-value to place indicator arrow at
- compute_xaxis() Tuple[Any][source]¶
computes and returns various elements necessary for adding the x-axis to the canvas
Parameters
Raises
- Returns
- circles_x
np.ndarray
x-values to draw circles denoting x-ticks
- circles_y
np.ndarray
y-values to draw circles denoting x-ticks
- xtickpos_x
np.ndarray
x-values to place x-ticklabels at
- xtickpos_y
np.ndarray
y-values to place x-ticklabels at
- xticklabs
np.ndarray
text to be displayed as x-ticklabels
- xlabpos_x
float
x-value to place x-label at
- xlabpos_y
float
y-value to place x-label at
- compute_ylabel() Tuple[Any][source]¶
computes and returns coordinates of for positioning the ylabel
Parameters
Raises
- Returns
- ylabpos_x
float
x-value to place y-label at
- ylabpos_y
float
y-value to place y-label at
- get_panel(theta: float) LSteinPanel[source]¶
returns a panel associated with theta
method to get panel associated with theta
only returns the first match
- Parameters
- theta
float
theta-value to extract panel of
Raises
- Returns
- panel
LSteinPanel, None
panel associated with theta
None if no panel associated with theta
- get_thetas() List[float][source]¶
returns theta of all currently added panels
helper method to get theta of all currently added panels
Parameters
Raises
- Returns
- thetas
List[float]
theta values associated with each panel in self.Panels
- plot(theta: ndarray, X: List[ndarray], Y: List[ndarray], seriestype: List[str] | Literal['line', 'scatter'] = 'line', panel_kwargs: List[Dict] | Dict = None, series_kwargs: List[Dict] | Dict = None)[source]¶
adds all series defined in theta, X, Y to respective panels for plotting
convenience function to plot a set of series
will add all of the passed series to respective panels
- Parameters
- theta
np.ndarray
theta values associated for to each series in zip(X,Y)
2.5th dimension
- X
List[np.ndarray]
set of x-values of each series
has to have same length as theta
- can contain arrays of different lengths
have to have same length as corresponding entries in Y
each series will be plotted in it’s own panel associated with theta
- Y
List[np.ndarray]
set of y-values of each series
has to have same length as theta
- can contain arrays of different lengths
have to have same length as corresponding entries in y
each series will be plotted in it’s own panel associated with theta
- seriestpye
Literal[“line”,”scatter”], List[str], optional
- which style to use for plotting the series
“line” – line plot “scatter” – scatter plot
- if List[str]
has to have same length as X
applied to each series individually
- if Literal[]
applied to all series in X
the default is “line”
- panel_kwargs
List[Dict], Dict optional
kwargs to pass to self.add_panel()
- if List[Dict]
has to have same length as theta
the panel created for each theta will use the respective specifications
- if Dict
specifications will be applied to all created panels
- the default is None
will be set to dict() for all panels
- plot_kwargs
List[Dict], Dict, optional
kwargs to pass to LSteinPanel.plot()
- if List[Dict]
has to have same length as theta
the series plotted for each theta will use the respective specifications
- if Dict
specifications will be applied to all plotted series
- the default is None
will be set to dict() for all panels
Raises
Returns