Table Of Contents

Previous topic

Plotting extensions

This Page

Extensions to matplotlib

The plotlib module provides several additions to matplotlib.

Formatters

class EngrFormatter(ndec=None, useOffset=True, useMathText=False, strict=False)

A variation of the standard ScalarFormatter, using only multiples of three in the mantissa. A fixed number of decimals can be displayed with the optional parameter ndec.

Parameters:

ndec : {None, int}, optional

Number of decimals to be displayed. If None, the number of decimals is defined from the current ticks.

useOffest : {True, False}, optional

useMathTtest : {True, False}

strict : {False, True}

Attributes

axis

Methods

DummyAxis
create_dummy_axis
fix_minus
format_data
format_data_short
get_offset
pprint_val
set_axis
set_bounds
set_data_interval
set_locs
set_powerlimits
set_scientific
set_view_interval
class MinimalFormatter(sigfigs=None)

A minimal formatter: just the plain data !

Attributes

axis

Methods

DummyAxis
create_dummy_axis
fix_minus
format_data
format_data_short
get_offset
set_axis
set_bounds
set_data_interval
set_locs
set_view_interval

Functions

whiskerbox(series, fsp=None, positions=None, mode='mquantiles', width=0.80000000000000004, wisk=None, plot_mean=False, logscale=None, color=None, outliers=None)

Draws a whisker plot. The bottom and top of the boxes correspond to the lower and upper quartiles respectively (25th and 75th percentiles).

Parameters:

series : Sequence

Input data. If the sequence is 2D, each column is assumed to represent a different variable.

fsp : Subplot

Subplot where to draw the data. If None, uses the current axe.

positions : {None, sequence}, optional

Positions along the x-axis. If None, use a scale from 1 to the number of columns.

mode : {‘mquantiles’, ‘hdquantiles’}, optional

Type of algorithm used to compute the quantiles. If ‘mquantiles’, use the classical form mquantiles If ‘hdquantiles’, use the Harrell-Davies estimators of the function hdquantiles.

wisk : {None, float}, optional

Whiskers size, as a multiplier of the inter-quartile range. If None, the whiskers are drawn between the 5th and 95th percentiles.

plot_mean : {False, True}, optional

Whether to overlay the mean on the box.

color : {None, string}, optional

Color of the main box.

outliers : {dictionary}, optional

Options for plotting outliers. By default, the dictionary uses dict(marker='x', ms=4, mfc='#999999', ls='')

qqplot(data, distrib=<scipy.stats.distributions.norm_gen object at 0x1027fc550>, alpha=0.40000000000000002, beta=0.40000000000000002, fsp=None, plot_line=True, **kwargs)

Returns a quantile-quantile plot with theoretical quantiles in abscissae, and experimental quantiles in ordinates. The experimental quantiles are estimated through the equation:

q_i = \frac{i-\alpha}{n-\alpha-\beta}

where i is the rank order statistic, n the number of unmasked data and \alpha and \beta two parameters between 0 and 1. The default \alpha=\beta=0.4 gives approximately unbiased estimates of the quantiles.

Parameters:

data : array

Input data

distrib : {norm, function}, optional

Theoretical distribution used to compute the expected quantiles. If None, use a normal distribution.

alpha : {float} optional

Coefficient for the computation of plotting positions.

beta : {float} optional

Coefficient for the computation of plotting positions.

fsp : {None, Subplot}, optional

Subplot where to plot. If None, use the current axe.

plot_line : {True, False}

Whether to compute a regression line.

Returns:

plotted : matplotlib.lines.Line2D

Plotted data

lines : matplotlib.lines.Line2D

Plotted regression line

(a,b) : tuple

Slope and intercept of the regression line.

See also

scipy.stats.mstats.mquantiles
Computes quantiles from a population.

Notes

  • The distrib parameter must be a function with a ppf method.
  • The input data is ravelled beforehand.
set_normal_ticks(fsp=None)

Change the ticks of the x-axis to a gaussian quantiles.

Parameters:

fsp : {None,Subplot}

Subplot where to draw the data. If None, uses the current axis.

set_normal_limits(fsp, xmin=None, xmax=None, emit=True, scale='log')

Sets the limits of the xaxis for a normal plot.

Parameters:

xmin : {None, float}, optional

Lower limit of the axis, as a float between 0 and 1. If None, use the current limit.

xmax : {None, float}, optional

Upper limit of the axis, as a float between 0 and 1. If None, use the current limit.

emit : {True, False}, optional

Whether notify the observers of a limit change.

scale : {‘log’, ‘lin’}, optional

Whether the