API: Additional Plotting Functions#
Below are additional higher-level plotting functions provided by PyTTOP that offer useful features. You can import them via from pyttop.plot import ...
- refline = <pyttop PlotFunction refline(x=None, y=None, xpos=0.1, ypos=0.1, xtxt=None, ytxt=None, xfmt='.2f', yfmt='.2f', marker='', style='through', label=None, ax=None, **lineargs)>[source]#
Tip
This function is made compatible with
pyttop.table.Data.plots()and can be called in either of the following ways:refline(x=None, y=None, xpos=0.1, ypos=0.1, xtxt=None, ytxt=None, xfmt='.2f', yfmt='.2f', marker='', style='through', label=None, ax=None, **lineargs)refline(axis)(x=None, y=None, xpos=0.1, ypos=0.1, xtxt=None, ytxt=None, xfmt='.2f', yfmt='.2f', marker='', style='through', label=None, ax=None, **lineargs)
Plot reference line(s) and optionally marker(s) at given position(s).
This function adds vertical and/or horizontal lines to the plot, anchored at the specified x and/or y values. Optionally, marker(s) can be drawn at the intersection(s), and text annotations can be shown on the reference line(s) to indicate the values.
- Parameters:
x (float or Iterable, optional) – The x-coordinate(s) at which to draw vertical reference line(s). The default is None.
y (float or Iterable, optional) – The y-coordinate(s) at which to draw horizontal reference line(s). The default is None.
xpos (float or None, optional) – Relative x (horizontal) position (in axes fraction) for y-value annotation text. If None, no text is shown. The default is 0.1.
ypos (float or None, optional) – Relative y (vertical) position (in axes fraction) for x-value annotation text. If None, no text is shown. The default is 0.1.
xtxt (str, optional) – If not None, the x label text will be overwritten by this.
ytxt (str, optional) – If not None, the y label text will be overwritten by this.
xfmt (str, optional) – Format string for x label (if
xtxtnot specified). The default is'.2f'.yfmt (str, optional) – Format string for y label (if
ytxtnot specified). The default is'.2f'.marker (optional) – Marker style for the intersection point, if both x and y are provided. The default is ‘’ (no marker).
style ({'through', 'axis'}, optional) –
Line style:
'through': line(s) extend across the full axis.'axis': only plot line(s) on the left and/or beneath the point.
The default is
'through'.label (str, optional) – Label assigned to the line(s), useful for legends.
ax (matplotlib.axes.Axes, optional) – The axis on which to plot. If None, uses the current axis.
**lineargs – Additional keyword arguments passed to
ax.axhlineandax.axvline.
- binned_quantiles = <pyttop PlotFunction binned_quantiles(x, y, bin_size=0.1, bin_dist=0.1, quantiles=[0.16, 0.5, 0.84], min_n=10, xmin=None, xmax=None, show_scatter=True, s=None, c=None, label=None, show_bins=True, show_errorbars=True, emarker='o', es=5, ec=None, elabel=None, show_fill=False, fc=None, flabel=None, errkwargs={}, fillkwargs={}, **kwargs)>[source]#
Tip
This function is made compatible with
pyttop.table.Data.plots()and can be called in either of the following ways:binned_quantiles(x, y, bin_size=0.1, bin_dist=0.1, quantiles=[0.16, 0.5, 0.84], min_n=10, xmin=None, xmax=None, show_scatter=True, s=None, c=None, label=None, show_bins=True, show_errorbars=True, emarker='o', es=5, ec=None, elabel=None, show_fill=False, fc=None, flabel=None, errkwargs={}, fillkwargs={}, **kwargs)binned_quantiles(axis)(x, y, bin_size=0.1, bin_dist=0.1, quantiles=[0.16, 0.5, 0.84], min_n=10, xmin=None, xmax=None, show_scatter=True, s=None, c=None, label=None, show_bins=True, show_errorbars=True, emarker='o', es=5, ec=None, elabel=None, show_fill=False, fc=None, flabel=None, errkwargs={}, fillkwargs={}, **kwargs)
Plot sliding-window quantile errorbars/fill.
This function visualizes a 2D distribution by plotting raw (x, y) points and computing sliding-window quantiles in x-bins. It then overlays error bars and/or filled regions to represent variability (e.g. 16th–84th percentile) in y-values within each x-bin.
This is useful when visualizing scatter data along with robust estimates of central tendency and spread.
- Parameters:
x (array-like) – Data coordinates.
y (array-like) – Data coordinates.
bin_size (float, optional) – Width of each sliding bin in x-units. Default is 0.1.
bin_dist (float, optional) – Step size between consecutive bin positions (i.e., sliding window stride). Default is 0.1.
quantiles (list of 3 floats, optional) – List of quantiles to compute within each bin. Must be in increasing order. Default is [0.16, 0.50, 0.84].
min_n (int, optional) – Minimum number of data points required in a bin to compute quantiles. Default is 10.
xmin (float, optional) – Range of x-values to include in binning. If None, inferred from data.
xmax (float, optional) – Range of x-values to include in binning. If None, inferred from data.
show_scatter (bool, optional) – If True, plot the raw scatter points. Default is True.
s (optional) – Marker size and color for scatter points.
c (optional) – Marker size and color for scatter points.
label (str, optional) – Label for the scatter plot.
show_bins (bool, optional) – If True, include horizontal error bars showing bin width. Default is True.
show_errorbars (bool, optional) – If True, show vertical error bars (quantile-based). Default is True.
emarker (str, optional) – Marker style for error bar midpoints. Default is ‘o’.
es (float, optional) – Marker size for error bars. Default is 5.
ec (color, optional) – Color for error bars.
elabel (str, optional) – Label for the error bars. If None and
show_scatteris False, inheritslabel.show_fill (bool, optional) – If True, fills the area between lower and upper quantiles. Default is False.
fc (color, optional) – Fill color. If None, inherits from
ec.flabel (str, optional) – Label for the fill.
errkwargs (dict, optional) – Additional keyword arguments passed to
plt.errorbar.fillkwargs (dict, optional) – Additional keyword arguments passed to
plt.fill_between.**kwargs (dict) – Additional keyword arguments passed to the scatter plot.