Draw streamlines of a vector flow.
Evenly spaced strictly increasing arrays to make a grid. If 2D, all rows of x must be equal and all columns of y must be equal; i.e., they must be as if generated by np.meshgrid(x_1d, y_1d).
x and y-velocities. The number of rows and columns must match the length of y and x, respectively.
Controls the closeness of streamlines. When density = 1, the domain is divided into a 30x30 grid. density linearly scales this grid. Each cell in the grid can have, at most, one traversing streamline. For different densities in each direction, use a tuple (density_x, density_y).
The width of the stream lines. With a 2D array the line width can be varied across the grid. The array must have the same shape as u and v.
The streamline color. If given an array, its values are converted to colors using cmap and norm. The array must have the same shape as u and v.
Colormap used to plot streamlines and arrows. This is only used if color is an array.
Normalize object used to scale luminance data to 0, 1. If None, stretch (min, max) to (0, 1). This is only used if color is an array.
Scaling factor for the arrow size.
Arrow style specification. See FancyArrowPatch.
Minimum length of streamline in axes coordinates.
Coordinates of starting points for the streamlines in data coordinates (the same coordinates as the x and y arrays).
The zorder of the stream lines and arrows. Artists with lower zorder values are drawn first.
Maximum length of streamline in axes coordinates.
Integrate the streamline in forward, backward or both directions.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y, u, v, start_points
Container object with attributes
This container will probably change in the future to allow changes to the colormap, alpha, etc. for both lines and arrows, but these changes should be backward compatible.


Add an Axes to the current figure or retrieve an existing Axes.
This is a wrapper of Figure.add_subplot which provides additional behavior when working with the implicit API (see the notes section).
Call signatures:
The position of the subplot described by one of
The projection type of the subplot (Axes). str is the name of a custom projection, see projections. The default None results in a 'rectilinear' projection.
If True, equivalent to projection='polar'.
Share the x or y axis with sharex and/or sharey. The axis will have the same limits, ticks, and scale as the axis of the shared axes.
A label for the returned axes.
The axes of the subplot. The returned axes base class depends on the projection used. It is Axes if rectilinear projection is used and projections.polar.PolarAxes if polar projection is used. The returned axes is then a subplot subclass of the base class.
This method also takes the keyword arguments for the returned axes base class; except for the figure argument. The keyword arguments for the rectilinear base class Axes can be found in the following table but there might also be other keyword arguments if another projection is used.
Property
Description
adjustable
{'box', 'datalim'}
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
anchor
(float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}
animated
bool
aspect
{'auto', 'equal'} or float
autoscale_on
bool
autoscalex_on
bool
autoscaley_on
bool
axes_locator
Callable[[Axes, Renderer], Bbox]
axisbelow
bool or 'line'
box_aspect
float or None
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
facecolor or fc
color
figure
Figure
frame_on
bool
gid
str
in_layout
bool
label
object
navigate
bool
navigate_mode
unknown
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
[left, bottom, width, height] or Bbox
prop_cycle
unknown
rasterization_zorder
float or None
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
title
str
transform
Transform
url
str
visible
bool
xbound
unknown
xlabel
str
xlim
(bottom: float, top: float)
xmargin
float greater than -0.5
xscale
{"linear", "log", "symlog", "logit", ...} or ScaleBase
xticklabels
unknown
xticks
unknown
ybound
unknown
ylabel
str
ylim
(bottom: float, top: float)
ymargin
float greater than -0.5
yscale
{"linear", "log", "symlog", "logit", ...} or ScaleBase
yticklabels
unknown
yticks
unknown
zorder
float
See also
Creating a new Axes will delete any pre-existing Axes that overlaps with it beyond sharing a boundary:
If you do not want this behavior, use the Figure.add_subplot method or the pyplot.axes function instead.
If no kwargs are passed and there exists an Axes in the location specified by args then that Axes will be returned rather than a new Axes being created.
If kwargs are passed and there exists an Axes in the location specified by args, the projection type is the same, and the kwargs match with the existing Axes, then the existing Axes is returned. Otherwise a new Axes is created with the specified parameters. We save a reference to the kwargs which we use for this comparison. If any of the values in kwargs are mutable we will not detect the case where they are mutated. In these cases we suggest using Figure.add_subplot and the explicit Axes API rather than the implicit pyplot API.
Controlling view limits using margins and sticky_edges
Resizing axes with tight layout
Geographic Projections
Managing multiple figures in pyplot
Sharing axis limits and views
Shared Axis
Multiple subplots
Subplots spacings and margins
Bar chart on polar axis
Pyplot Two Subplots
Simple Colorbar
MATPLOTLIB UNCHAINED
Customize Rc
transforms.offset_copy
Pyplot tutorial
Constrained Layout Guide
Tight Layout guide


Create a subplot at a specific location inside a regular grid.
Number of rows and of columns of the grid in which to place axis.
Row number and column number of the axis location within the grid.
Number of rows for the axis to span downwards.
Number of columns for the axis to span to the right.
Figure to place the subplot in. Defaults to the current figure.
Additional keyword arguments are handed to add_subplot.
The axes of the subplot. The returned axes base class depends on the projection used. It is Axes if rectilinear projection is used and projections.polar.PolarAxes if polar projection is used. The returned axes is then a subplot subclass of the base class.
The following call
is identical to
Resizing axes with tight layout
subplot2grid demo
Constrained Layout Guide
Tight Layout guide


Build a layout of Axes based on ASCII art or nested lists.
This is a helper function to build complex GridSpec layouts visually.
Note
This API is provisional and may be revised in the future based on early user feedback.
A visual layout of how you want your Axes to be arranged labeled as strings. For example
produces 4 axes:
Any of the entries in the layout can be a list of lists of the same form to create nested layouts.
If input is a str, then it must be of the form
where each character is a column and each line is a row. This only allows only single character Axes labels and does not allow nesting but is very terse.
If True, the x-axis (sharex) or y-axis (sharey) will be shared among all subplots. In that case, tick label visibility and axis units behave as for subplots. If False, each subplot's x- or y-axis will be independent.
Dictionary with keywords passed to the Figure.add_subplot call used to create each subplot.
Dictionary with keywords passed to the GridSpec constructor used to create the grid the subplots are placed on.
Entry in the layout to mean "leave this space empty". Defaults to '.'. Note, if layout is a string, it is processed via inspect.cleandoc to remove leading white space, which may interfere with using white-space as the empty sentinel.
All additional keyword arguments are passed to the pyplot.figure call.
The new figure
A dictionary mapping the labels to the Axes objects. The order of the axes is left-to-right and top-to-bottom of their position in the total layout.
Image Demo
Labelling subplots
Basic Usage
Legend guide
Arranging multiple Axes in a Figure


Launch a subplot tool window for a figure.


Create a figure and a set of subplots.
This utility wrapper makes it convenient to create common layouts of subplots, including the enclosing figure object, in a single call.
Number of rows/columns of the subplot grid.
Controls sharing of properties among x (sharex) or y (sharey) axes:
When subplots have a shared x-axis along a column, only the x tick labels of the bottom subplot are created. Similarly, when subplots have a shared y-axis along a row, only the y tick labels of the first column subplot are created. To later turn other subplots' ticklabels on, use tick_params.
When subplots have a shared axis that has units, calling set_units will update each axis with the new units.
If True, extra dimensions are squeezed out from the returned array of Axes:
Dict with keywords passed to the add_subplot call used to create each subplot.
Dict with keywords passed to the GridSpec constructor used to create the grid the subplots are placed on.
All additional keyword arguments are passed to the pyplot.figure call.
ax can be either a single Axes object or an array of Axes objects if more than one subplot was created. The dimensions of the resulting array can be controlled with the squeeze keyword, see above.
Typical idioms for handling the return value are:
The names ax and pluralized axs are preferred over axes because for the latter it's not clear if it refers to a single Axes instance or a collection of these.
See also
Bar Label Demo
Stacked bar chart
Grouped bar chart with labels
Horizontal bar chart
Broken Barh
Plotting categorical variables
Plotting the coherence of two signals
CSD Demo
Curve with error band
Errorbar subsampling
Eventplot Demo
Filled polygon
Fill Between and Alpha
Filling the area between lines
Fill Betweenx Demo
Hatch-filled histograms
Bar chart with gradients
Hat graph
Discrete distribution as horizontal bar chart
Customizing dashed line styles
Lines with a ticked patheffect
Marker reference
Multicolored lines
Psd Demo
Scatter Custom Symbol
Scatter Demo2
Scatter plot with pie chart markers
Marker examples
Scatter plots with a legend
Simple Plot
Using span_where
Spectrum Representations
Stackplots and streamgraphs
Stairs Demo
Creating a timeline with lines, dates, and text
hlines and vlines
Cross- and Auto-Correlation Demo
Affine transform of an image
Wind Barbs
Contour Corner Mask
Contour Demo
Contour Image
Contour Label Demo
Contourf Demo
Contourf Hatching
Contourf and log color scale
Contouring the solution space of optimizations
BboxImage Demo
Creating annotated heatmaps
Image antialiasing
Clipping images with patches
Image Demo
Image Masked
Image Nonuniform
Blend transparency with color in 2D images
Modifying the coordinate formatter
Interpolations for imshow
Contour plot of irregularly spaced data
Multi Image
Pcolor Demo
pcolormesh grids and shading
pcolormesh
QuadMesh Demo
Advanced quiver and quiverkey functions
Quiver Simple Demo
Shading example
Spectrogram Demo
Spy Demos
Tricontour Demo
Tricontour Smooth Delaunay
Tricontour Smooth User
Trigradient Demo
Triinterp Demo
Tripcolor Demo
Triplot Demo
Watermark image
Axes box aspect
Axes Demo
Controlling view limits using margins and sticky_edges
Axes Props
axhspan Demo
Equal axis aspect ratio
Axis Label Position
Broken Axis
Placing Colorbars
Resizing axes with constrained layout
Resizing axes with tight layout
Different scales on the same axes
Figure size in different units
Figure labels: suptitle, supxlabel, supylabel
Creating adjacent subplots
Combining two subplots using subplots and GridSpec
Invert Axes
Secondary Axis
Figure subfigures
Multiple subplots
Creating multiple subplots using plt.subplots
Plots with different scales
Zoom region inset axes
Percentiles as horizontal bar chart
Artist customization in box plots
Box plots with custom fill colors
Boxplots
Box plot vs. violin plot comparison
Boxplot drawer function
Plot a confidence ellipse of a two-dimensional dataset
Violin plot customization
Errorbar function
Different ways of specifying error bars
Including upper and lower limits in error bars
Creating boxes from error bars using PatchCollection
Hexagonal binned plot
Histograms
Using histograms to plot a cumulative distribution
Some features of the histogram (hist) function
Demo of the histogram function's different histtype settings
The histogram (hist) function with multiple data sets
Producing multiple histograms side by side
Time Series Histogram
Violin plot basics
Basic pie chart
Pie Demo2
Bar of pie
Nested pie charts
Labeling a pie and a donut
Polar plot
Using accented text in matplotlib
Scale invariant angle label
Annotating Plots
Composing Custom Legends
Date tick labels
Custom tick formatter for time series
AnnotationBbox demo
Using a text as a Path
Labeling ticks using engineering notation
Figure legend demo
Configuring the font family
Using a ttf font file in Matplotlib
Font table
Legend using pre-defined labels
Legend Demo
Artist within an artist
Mathtext
Math fontfamily
Multiline
Placing text boxes
Rendering math equations using TeX
Precise text layout
Default text rotation demonstration
Text Rotation Relative To Line
Title positioning
Text watermark
Align y-labels
Annotate Transform
Annotating a plot
Programmatically controlling subplot adjustment
Boxplot Demo
Dollar Ticks
Color Demo
Color by y-value
Colors in the default property cycle
Colorbar
Colormap reference
Creating a colormap from a list of colors
List of named colors
Arrow guide
Reference for Matplotlib artists
Line, Poly and RegularPoly Collection with autoscaling
Compound path
Dolphins
Mmh Donuts!!!
Ellipse Collection
Ellipse Demo
Drawing fancy boxes
Hatch style reference
Line Collection
Circles, Wedges and Polygons
PathPatch object
Bezier Curve
Bayesian Methods for Hackers style sheet
Dark background style sheet
FiveThirtyEight style sheet
ggplot style sheet
Grayscale style sheet
Style sheets reference
Anchored Direction Arrow
HBoxDivider demo
Showing RGB channels using RGBAxes
Adding a colorbar to inset axes
Colorbar with AxesDivider
Controlling the position and size of colorbars with Inset Axes
Inset Locator Demo
Inset Locator Demo2
Scatter Histogram (Locatable Axes)
Simple Anchored Artists
Bachelor's degrees by gender
Integral as the area under a curve
Decay
Animated histogram
pyplot animation
The Bayes update
Animated image using a precomputed list of images
Pausing and Resuming an Animation
Animated line plot
Oscilloscope
Mouse move and click events
Data Browser
Figure/Axes enter and leave events
Image Slices Viewer
Keypress event
Legend Picking
Looking Glass
Path Editor
Pick Event Demo
Pick Event Demo2
Poly Editor
Pong
Resampling Data
Timers
Trifinder Event Demo
Viewlims
Zoom Window
Frontpage 3D example
Frontpage contour example
Frontpage histogram example
Frontpage plot example
Anchored Artists
Changing colors of lines intersecting a box
Manual Contour
Coords Report
Cross hair cursor
Custom projection
AGG filter
Ribbon Box
Findobj Demo
Building histograms using Rectangles and PolyCollections
Plotting with keywords
Multiprocess
Packed-bubble chart
Patheffect Demo
Pythonic Matplotlib
Rasterization for vector graphics
TickedStroke patheffect
Zorder Demo
Custom hillshading in a 3D surface plot
3D stem
3D surface (colormap)
3D wireframe plots in one direction
Loglog Aspect
Log Bar
Log Demo
Log Axis
Logit Demo
Exploring normalizations
Scales
Symlog Demo
Hillshading
Anscombe's quartet
Left ventricle bullseye
MRI
Radar chart (aka spider or star chart)
Topographic hillshading
Centered spines with arrows
Multiple Yaxis With Spines
Spines
Custom spine bounds
Dropped spines
Automatically setting tick positions
Centering labels between ticks
Colorbar Tick Labelling
Custom Ticker1
Formatting date ticks using ConciseDateFormatter
Date Demo Convert
Placing date ticks using recurrence rules
Date Index Formatter
Date Precision and Epochs
Major and minor ticks
The default tick formatter
Tick formatters
Tick locators
Set default y-axis tick labels on the right
Setting tick labels from a list of values
Set default x-axis tick labels on the top
Annotation with units
Artist tests
Bar demo with units
Group barchart with units
Evans test
Radian ticks
Inches and Centimeters
Unit handling
pyplot with GTK3
pyplot with GTK4
SVG Tooltip
Anchored Box04
Annotate Explain
Annotate Simple01
Annotate Simple02
Annotate Simple03
Annotate Simple04
Annotate Simple Coord01
Annotate Simple Coord02
Annotate Simple Coord03
Annotate Text Arrow
Interactive Adjustment of Colormap Range
Colormap Normalizations
Colormap Normalizations Symlognorm
Connect Simple01
Connection styles for annotations
Custom box styles
Pgf Fonts
Pgf Preamble
Pgf Texsystem
Simple Annotate01
Simple Legend02
Annotated Cursor
Buttons
Check Buttons
Cursor
Lasso Selector
Mouse Cursor
Multicursor
Polygon Selector
Radio Buttons
Thresholding an Image with RangeSlider
Slider
Snapping Sliders to Discrete Values
Span Selector
Textbox
Basic Usage
The Lifecycle of a Plot
Artist tutorial
Legend guide
Styling with cycler
Constrained Layout Guide
Tight Layout guide
Arranging multiple Axes in a Figure
Autoscaling
Faster rendering by using blitting
Path Tutorial
Transformations Tutorial
Specifying Colors
Customized Colorbars Tutorial
Creating Colormaps in Matplotlib
Colormap Normalization
Choosing Colormaps in Matplotlib
Text in Matplotlib Plots
Annotations
plot(x, y)
scatter(x, y)
bar(x, height) / barh(y, width)
stem(x, y)
step(x, y)
fill_between(x, y1, y2)
imshow(Z)
pcolormesh(X, Y, Z)
contour(X, Y, Z)
contourf(X, Y, Z)
barbs(X, Y, U, V)
quiver(X, Y, U, V)
streamplot(X, Y, U, V)
hist(x)
boxplot(X)
errorbar(x, y, yerr, xerr)
violinplot(D)
eventplot(D)
hist2d(x, y)
hexbin(x, y, C)
pie(x)
tricontour(x, y, z)
tricontourf(x, y, z)
tripcolor(x, y, z)
triplot(x, y)


Adjust the subplot layout parameters.
Unset parameters are left unmodified; initial values are given by rcParams["figure.subplot.[name]"].
The position of the left edge of the subplots, as a fraction of the figure width.
The position of the right edge of the subplots, as a fraction of the figure width.
The position of the bottom edge of the subplots, as a fraction of the figure height.
The position of the top edge of the subplots, as a fraction of the figure height.
The width of the padding between subplots, as a fraction of the average Axes width.
The height of the padding between subplots, as a fraction of the average Axes height.
Contour plot of irregularly spaced data
Subplots spacings and margins
Violin plot customization
Controlling style of text and labels using a dictionary
Parasite axis demo
Table Demo
Rotating custom tick labels
Buttons
Check Buttons
Radio Buttons
Thresholding an Image with RangeSlider
Slider
Snapping Sliders to Discrete Values
Pyplot tutorial


Set the colormap to 'summer'.
This changes the default colormap as well as the colormap of the current image if there is one. See help(colormaps) for more information.


Add a centered suptitle to the figure.
The suptitle text.
The x location of the text in figure coordinates.
The y location of the text in figure coordinates.
The horizontal alignment of the text relative to (x, y).
The vertical alignment of the text relative to (x, y).
The font size of the text. See Text.set_size for possible values.
The font weight of the text. See Text.set_weight for possible values.
The Text instance of the suptitle.
A dict of font properties. If fontproperties is given the default values for font size and weight are taken from the FontProperties defaults. rcParams["figure.titlesize"] (default: 'large') and rcParams["figure.titleweight"] (default: 'normal') are ignored in this case.
Additional kwargs are matplotlib.text.Text properties.
Nested Gridspecs
Pyplot tutorial
Constrained Layout Guide


Close all open figures and set the Matplotlib backend.
The argument is case-insensitive. Switching to an interactive backend is possible only if no event loop for another interactive backend has started. Switching to and from non-interactive backends is always possible.
The name of the backend to use.


Add a table to an Axes.
At least one of cellText or cellColours must be specified. These parameters must be 2D lists, in which the outer lists define the rows and the inner list define the column values per row. Each row must have the same number of elements.
The table can optionally have row and column headers, which are configured using rowLabels, rowColours, rowLoc and colLabels, colColours, colLoc respectively.
For finer grained control over tables, use the Table class and add it to the axes with Axes.add_table.
The texts to place into the table cells.
Note: Line breaks in the strings are currently not accounted for and will result in the text exceeding the cell boundaries.
The background colors of the cells.
The alignment of the text within the cells.
The column widths in units of the axes. If not given, all columns will have a width of 1 / ncols.
The text of the row header cells.
The colors of the row header cells.
The text alignment of the row header cells.
The text of the column header cells.
The colors of the column header cells.
The text alignment of the column header cells.
The position of the cell with respect to ax. This must be one of the codes.
A bounding box to draw the table into. If this is not None, this overrides loc.
The cell edges to be drawn with a line. See also visible_edges.
The created table.
Table properties.
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
figure
Figure
fontsize
float
gid
str
in_layout
bool
label
object
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Table Demo


Add text to the Axes.
Add the text s to the Axes at location x, y in data coordinates.
The position to place the text. By default, this is in data coordinates. The coordinate system can be changed using the transform parameter.
The text.
A dictionary to override the default text properties. If fontdict is None, the defaults are determined by rcParams.
The created Text instance.
Other miscellaneous text parameters.
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
backgroundcolor
color
bbox
dict with properties for patches.FancyBboxPatch
clip_box
unknown
clip_on
unknown
clip_path
unknown
color or c
color
figure
Figure
fontfamily or family
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties or font or font_properties
font_manager.FontProperties or str or pathlib.Path
fontsize or size
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch or stretch
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle or style
{'normal', 'italic', 'oblique'}
fontvariant or variant
{'normal', 'small-caps'}
fontweight or weight
{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gid
str
horizontalalignment or ha
{'center', 'right', 'left'}
in_layout
bool
label
object
linespacing
float (multiple of font size)
math_fontfamily
str
multialignment or ma
{'left', 'right', 'center'}
parse_math
bool
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
(float, float)
rasterized
bool
rotation
float or {'vertical', 'horizontal'}
rotation_mode
{None, 'default', 'anchor'}
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
text
object
transform
Transform
transform_rotates_text
bool
url
str
usetex
bool or None
verticalalignment or va
{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visible
bool
wrap
bool
x
float
y
float
zorder
float
Individual keyword arguments can be used to override any given parameter:
The default transform specifies that text is in data coords, alternatively, you can specify text in axis coords ((0, 0) is lower-left and (1, 1) is upper-right). The example below places text in the center of the Axes:
You can put a rectangular box around the text instance (e.g., to set a background color) by using the keyword bbox. bbox is a dictionary of Rectangle properties. For example:
Figure size in different units
Auto-wrapping text
Styling text boxes
Controlling style of text and labels using a dictionary
Pyplot Mathtext
Pyplot Text
Reference for Matplotlib artists
Close Event
transforms.offset_copy
Pyplot tutorial
Path effects guide
Text properties and layout
Annotations


Get or set the theta gridlines on the current polar plot.
Call signatures:
When called with no arguments, thetagrids simply returns the tuple (lines, labels). When called with arguments, the labels will appear at the specified angles.
The angles of the theta gridlines.
The labels to use at each radial gridline. The projections.polar.ThetaFormatter will be used if None.
Format string used in matplotlib.ticker.FormatStrFormatter. For example '%f'. Note that the angle in radians will be used.
The theta gridlines.
The tick labels.
kwargs are optional Text properties for the labels.
See also


Change the appearance of ticks, tick labels, and gridlines.
Tick properties that are not explicitly set using the keyword arguments remain unchanged unless reset is True.
The axis to which the parameters are applied.
The group of ticks to which the parameters are applied.
Whether to reset the ticks to defaults before updating them.
Puts ticks inside the axes, outside the axes, or both.
Tick length in points.
Tick width in points.
Tick color.
Distance in points between tick and label.
Tick label font size in points or as a string (e.g., 'large').
Tick label color.
Tick color and label color.
Tick and label zorder.
Whether to draw the respective ticks.
Whether to draw the respective tick labels.
Tick label rotation
Gridline color.
Transparency of gridlines: 0 (transparent) to 1 (opaque).
Width of gridlines in points.
Any valid Line2D line style spec.
This will make all major ticks be red, pointing out of the box, and with dimensions 6 points by 2 points. Tick labels will also be red. Gridlines will be red and translucent.
Shared Axis


Configure the ScalarFormatter used by default for linear axes.
If a parameter is not set, the corresponding property of the formatter is left unchanged.
The axis to configure. Only major ticks are affected.
Whether to use scientific notation. The formatter default is to use scientific notation.
Scientific notation is used only for numbers outside the range 10m to 10n (and only if the formatter is configured to use scientific notation at all). Use (0, 0) to include all numbers. Use (m, m) where m != 0 to fix the order of magnitude to 10m. The formatter default is rcParams["axes.formatter.limits"] (default: [-5, 6]).
If True, the offset is calculated as needed. If False, no offset is used. If a numeric value, it sets the offset. The formatter default is rcParams["axes.formatter.useoffset"] (default: True).
Whether to format the number using the current locale or using the C (English) locale. This affects e.g. the decimal separator. The formatter default is rcParams["axes.formatter.use_locale"] (default: False).
Render the offset and scientific notation in mathtext. The formatter default is rcParams["axes.formatter.use_mathtext"] (default: False).
If the current formatter is not a ScalarFormatter.


Adjust the padding between and around subplots.
To exclude an artist on the Axes from the bounding box calculation that determines the subplot parameters (i.e. legend, or annotation), set a.set_in_layout(False) for that artist.
Padding between the figure edge and the edges of subplots, as a fraction of the font size.
Padding (height/width) between edges of adjacent subplots, as a fraction of the font size.
A rectangle in normalized figure coordinates into which the whole subplots area (including labels) will fit.
See also
Linestyles
Marker examples
Creating annotated heatmaps
Interpolations for imshow
Streamplot
Resizing axes with tight layout
Labeling ticks using engineering notation
Figure legend demo
Reference for Matplotlib artists
Zorder Demo
3D wireframe plots in one direction
MRI With EEG
Tick locators
Tight Layout guide


Set a title for the Axes.
Set one of the three available Axes titles. The available titles are positioned above the Axes in the center, flush with the left edge, and flush with the right edge.
Text to use for the title
A dictionary controlling the appearance of the title text, the default fontdict is:
Which title to set.
Vertical Axes loation for the title (1.0 is the top). If None (the default), y is determined automatically to avoid decorators on the Axes.
The offset of the title from the top of the Axes, in points.
The matplotlib text instance representing the title
Other keyword arguments are text properties, see Text for a list of valid text properties.
prop_cycle property markevery in rcParams
Plotting masked and NaN values
Stairs Demo
Step Demo
Geographic Projections
Multiple subplots
Controlling style of text and labels using a dictionary
Title positioning
Pyplot Mathtext
Pyplot Text
Solarized Light stylesheet
Interactive functions
Findobj Demo
Multipage PDF
Set and get properties
Table Demo
Zorder Demo
Custom scale
The Sankey class
SVG Histogram
Basic Usage
Pyplot tutorial


Draw contour lines on an unstructured triangular grid.
The triangulation can be specified in one of two ways; either
where triangulation is a Triangulation object, or
in which case a Triangulation object will be created. See that class' docstring for an explanation of these cases.
The remaining arguments may be:
where Z is the array of values to contour, one per point in the triangulation. The level values are chosen automatically.
contour up to levels+1 automatically chosen contour levels (levels intervals).
draw contour lines at the values specified in sequence levels, which must be in increasing order.
Use keyword arguments to control colors, linewidth, origin, cmap ... see below for more details.
The unstructured triangular grid.
If specified, then x, y, triangles, and mask are not accepted.
The coordinates of the values in Z.
For each triangle, the indices of the three points that make up the triangle, ordered in an anticlockwise manner. If not specified, the Delaunay triangulation is calculated.
Which triangles are masked out.
The height values over which the contour is drawn.
Determines the number and positions of the contour lines / regions.
If an int n, use MaxNLocator, which tries to automatically choose no more than n+1 "nice" contour levels between vmin and vmax.
If array-like, draw contour lines at the specified levels. The values must be in increasing order.
The colors of the levels, i.e., the contour lines.
The sequence is cycled for the levels in ascending order. If the sequence is shorter than the number of levels, it's repeated.
As a shortcut, single color strings may be used in place of one-element lists, i.e. 'red' instead of ['red'] to color all levels with the same color. This shortcut does only work for color strings, not for other ways of specifying colors.
By default (value None), the colormap specified by cmap will be used.
The alpha blending value, between 0 (transparent) and 1 (opaque).
A Colormap instance or registered colormap name. The colormap maps the level values to colors.
If both colors and cmap are given, an error is raised.
If a colormap is used, the Normalize instance scales the level values to the canonical colormap range [0, 1] for mapping to colors. If not given, the default linear scaling is used.
If not None, either or both of these values will be supplied to the Normalize instance, overriding the default color scaling based on levels.
Determines the orientation and exact position of Z by specifying the position of Z[0, 0]. This is only relevant, if X, Y are not given.
If origin is not None, then extent is interpreted as in imshow: it gives the outer pixel boundaries. In this case, the position of Z[0, 0] is the center of the pixel, not a corner. If origin is None, then (x0, y0) is the position of Z[0, 0], and (x1, y1) is the position of Z[-1, -1].
This argument is ignored if X and Y are specified in the call to contour.
The locator is used to determine the contour levels if they are not given explicitly via levels. Defaults to MaxNLocator.
Determines the tricontour-coloring of values that are outside the levels range.
If 'neither', values outside the levels range are not colored. If 'min', 'max' or 'both', color the values below, above or below and above the levels range.
Values below min(levels) and above max(levels) are mapped to the under/over values of the Colormap. Note that most colormaps do not have dedicated colors for these by default, so that the over and under values are the edge values of the colormap. You may want to set these values explicitly using Colormap.set_under and Colormap.set_over.
Note
An existing TriContourSet does not get notified if properties of its colormap are changed. Therefore, an explicit call to ContourSet.changed() is needed after modifying the colormap. The explicit call can be left out, if a colorbar is assigned to the TriContourSet because it internally calls ContourSet.changed().
Override axis units by specifying an instance of a matplotlib.units.ConversionInterface.
Enable antialiasing, overriding the defaults. For filled contours, the default is True. For line contours, it is taken from rcParams["lines.antialiased"] (default: True).
The line width of the contour lines.
If a number, all levels will be plotted with this linewidth.
If a sequence, the levels in ascending order will be plotted with the linewidths in the order specified.
If None, this falls back to rcParams["lines.linewidth"] (default: 1.5).
If linestyles is None, the default is 'solid' unless the lines are monochrome. In that case, negative contours will take their linestyle from rcParams["contour.negative_linestyle"] (default: 'dashed') setting.
linestyles can also be an iterable of the above strings specifying a set of linestyles to be used. If this iterable is shorter than the number of contour levels it will be repeated as necessary.


Draw contour regions on an unstructured triangular grid.
The triangulation can be specified in one of two ways; either
where triangulation is a Triangulation object, or
in which case a Triangulation object will be created. See that class' docstring for an explanation of these cases.
The remaining arguments may be:
where Z is the array of values to contour, one per point in the triangulation. The level values are chosen automatically.
contour up to levels+1 automatically chosen contour levels (levels intervals).
draw contour regions at the values specified in sequence levels, which must be in increasing order.
Use keyword arguments to control colors, linewidth, origin, cmap ... see below for more details.
The unstructured triangular grid.
If specified, then x, y, triangles, and mask are not accepted.
The coordinates of the values in Z.
For each triangle, the indices of the three points that make up the triangle, ordered in an anticlockwise manner. If not specified, the Delaunay triangulation is calculated.
Which triangles are masked out.
The height values over which the contour is drawn.
Determines the number and positions of the contour lines / regions.
If an int n, use MaxNLocator, which tries to automatically choose no more than n+1 "nice" contour levels between vmin and vmax.
If array-like, draw contour lines at the specified levels. The values must be in increasing order.
The colors of the levels, i.e., the contour regions.
The sequence is cycled for the levels in ascending order. If the sequence is shorter than the number of levels, it's repeated.
As a shortcut, single color strings may be used in place of one-element lists, i.e. 'red' instead of ['red'] to color all levels with the same color. This shortcut does only work for color strings, not for other ways of specifying colors.
By default (value None), the colormap specified by cmap will be used.
The alpha blending value, between 0 (transparent) and 1 (opaque).
A Colormap instance or registered colormap name. The colormap maps the level values to colors.
If both colors and cmap are given, an error is raised.
If a colormap is used, the Normalize instance scales the level values to the canonical colormap range [0, 1] for mapping to colors. If not given, the default linear scaling is used.
If not None, either or both of these values will be supplied to the Normalize instance, overriding the default color scaling based on levels.
Determines the orientation and exact position of Z by specifying the position of Z[0, 0]. This is only relevant, if X, Y are not given.
If origin is not None, then extent is interpreted as in imshow: it gives the outer pixel boundaries. In this case, the position of Z[0, 0] is the center of the pixel, not a corner. If origin is None, then (x0, y0) is the position of Z[0, 0], and (x1, y1) is the position of Z[-1, -1].
This argument is ignored if X and Y are specified in the call to contour.
The locator is used to determine the contour levels if they are not given explicitly via levels. Defaults to MaxNLocator.
Determines the tricontourf-coloring of values that are outside the levels range.
If 'neither', values outside the levels range are not colored. If 'min', 'max' or 'both', color the values below, above or below and above the levels range.
Values below min(levels) and above max(levels) are mapped to the under/over values of the Colormap. Note that most colormaps do not have dedicated colors for these by default, so that the over and under values are the edge values of the colormap. You may want to set these values explicitly using Colormap.set_under and Colormap.set_over.
Note
An existing TriContourSet does not get notified if properties of its colormap are changed. Therefore, an explicit call to ContourSet.changed() is needed after modifying the colormap. The explicit call can be left out, if a colorbar is assigned to the TriContourSet because it internally calls ContourSet.changed().
Override axis units by specifying an instance of a matplotlib.units.ConversionInterface.
Enable antialiasing, overriding the defaults. For filled contours, the default is True. For line contours, it is taken from rcParams["lines.antialiased"] (default: True).
A list of cross hatch patterns to use on the filled areas. If None, no hatching will be added to the contour. Hatching is supported in the PostScript, PDF, SVG and Agg backends only.
tricontourf fills intervals that are closed at the top; that is, for boundaries z1 and z2, the filled region is:
except for the lowest interval, which is closed on both sides (i.e. it includes the lowest value).


Create a pseudocolor plot of an unstructured triangular grid.
The triangulation can be specified in one of two ways; either:
where triangulation is a Triangulation object, or
in which case a Triangulation object will be created. See Triangulation for a explanation of these possibilities.
The next argument must be C, the array of color values, either one per point in the triangulation if color values are defined at points, or one per triangle in the triangulation if color values are defined at triangles. If there are the same number of points and triangles in the triangulation it is assumed that color values are defined at points; to force the use of color values at triangles use the kwarg facecolors=C instead of just C.
shading may be 'flat' (the default) or 'gouraud'. If shading is 'flat' and C values are defined at points, the color values used for each triangle are from the mean C of the triangle's three points. If shading is 'gouraud' then color values must be defined at points.
The remaining kwargs are the same as for pcolor.


Draw a unstructured triangular grid as lines and/or markers.
The triangulation to plot can be specified in one of two ways; either:
where triangulation is a Triangulation object, or
in which case a Triangulation object will be created. See Triangulation for a explanation of these possibilities.
The remaining args and kwargs are the same as for plot.
The drawn triangles edges.
The drawn marker nodes.


Make and return a second axes that shares the x-axis. The new axes will overlay ax (or the current axes if ax is None), and its ticks will be on the right.
Plots with different scales


Make and return a second axes that shares the y-axis. The new axes will overlay ax (or the current axes if ax is None), and its ticks will be on the top.
Plots with different scales


Uninstall the Matplotlib display hook.
Warning
Need IPython >= 2 for this to work. For IPython < 2 will raise a NotImplementedError
Warning
If you are using vanilla python and have installed another display hook, this will reset sys.displayhook to what ever function was there when Matplotlib installed its displayhook, possibly discarding your changes.


Make a violin plot.
Make a violin plot for each column of dataset or each vector in sequence dataset. Each filled area extends to represent the entire data range, with optional lines at the mean, the median, the minimum, the maximum, and user-specified quantiles.
The input data.
The positions of the violins. The ticks and limits are automatically set to match the positions.
If true, creates a vertical violin plot. Otherwise, creates a horizontal violin plot.
Either a scalar or a vector that sets the maximal width of each violin. The default is 0.5, which uses about half of the available horizontal space.
If True, will toggle rendering of the means.
If True, will toggle rendering of the extrema.
If True, will toggle rendering of the medians.
If not None, set a list of floats in interval [0, 1] for each violin, which stands for the quantiles that will be rendered for that violin.
Defines the number of points to evaluate each of the gaussian kernel density estimations at.
The method used to calculate the estimator bandwidth. This can be 'scott', 'silverman', a scalar constant or a callable. If a scalar, this will be used directly as kde.factor. If a callable, it should take a GaussianKDE instance as its only parameter and return a scalar. If None (default), 'scott' is used.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
dataset
A dictionary mapping each component of the violinplot to a list of the corresponding collection instances created. The dictionary has the following keys:


Set the colormap to 'viridis'.
This changes the default colormap as well as the colormap of the current image if there is one. See help(colormaps) for more information.


Plot vertical lines at each x from ymin to ymax.
x-indexes where to plot the lines.
Respective beginning and end of each line. If scalars are provided, all lines will have same length.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, ymin, ymax, colors
See also
horizontal lines
vertical line across the Axes


Blocking call to interact with the figure.
Wait for user input and return True if a key was pressed, False if a mouse button was pressed and None if no input was given within timeout seconds. Negative values deactivate timeout.
Interactive functions


Set the colormap to 'winter'.
This changes the default colormap as well as the colormap of the current image if there is one. See help(colormaps) for more information.


Plot the cross correlation between x and y.
The correlation with lag k is defined as \(\sum_n x[n+k] \cdot y^*[n]\), where \(y^*\) is the complex conjugate of \(y\).
A detrending function applied to x and y. It must have the signature
If True, input vectors are normalised to unit length.
Determines the plot style.
If True, vertical lines are plotted from 0 to the xcorr value using Axes.vlines. Additionally, a horizontal line is plotted at y=0 using Axes.axhline.
If False, markers are plotted at the xcorr values using Axes.plot.
Number of lags to show. If None, will return all 2 * len(x) - 1 lags.
The lag vector.
The auto correlation vector.
Artist added to the Axes of the correlation:
Horizontal line at 0 if usevlines is True None usevlines is False.
The linestyle for plotting the data points. Only used if usevlines is False.
The marker for plotting the data points. Only used if usevlines is False.
If given, the following parameters also accept a string s, which is interpreted as data[s] (unless this raises an exception):
x, y
Additional parameters are passed to Axes.vlines and Axes.axhline if usevlines is True; otherwise they are passed to Axes.plot.
The cross correlation is performed with numpy.correlate with mode = "full".


Turn on xkcd sketch-style drawing mode. This will only have effect on things drawn after this function is called.
For best results, the "Humor Sans" font should be installed: it is not included with Matplotlib.
The amplitude of the wiggle perpendicular to the source line.
The length of the wiggle along the line.
The scale factor by which the length is shrunken or expanded.
This function works by a number of rcParams, so it will probably override others you have set before.
If you want the effects of this function to be temporary, it can be used as a context manager, for example:
XKCD


Set the label for the x-axis.
The label text.
Spacing in points from the Axes bounding box including ticks and tick labels. If None, the previous value is left as is.
The label position. This is a high-level alternative for passing parameters x and horizontalalignment.
Text properties control the appearance of the label.
See also
Documents the properties supported by Text.
Scatter Symbol
Multiple subplots
Controlling style of text and labels using a dictionary
Infinite lines
Pyplot Mathtext
Pyplot Text
Solarized Light stylesheet
Findobj Demo
Custom scale
Basic Usage
Pyplot tutorial


Get or set the x limits of the current axes.
Call signatures:
If you do not specify args, you can pass left or right as kwargs, i.e.:
Setting limits turns autoscaling off for the x-axis.
A tuple of the new x-axis limits.
Calling this function with no arguments (e.g. xlim()) is the pyplot equivalent of calling get_xlim on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_xlim on the current axes. All arguments are passed though.
Shared Axis
Infinite lines
Pyplot Text
Frame grabbing
Interactive functions


Set the x-axis scale.
The axis scale type to apply.
Different keyword arguments are accepted, depending on the scale. See the respective class keyword arguments:
By default, Matplotlib supports the above mentioned scales. Additionally, custom scales may be registered using matplotlib.scale.register_scale. These scales can then also be used here.


Get or set the current tick locations and labels of the x-axis.
Pass no arguments to return the current values without modifying them.
The list of xtick locations. Passing an empty list removes all xticks.
The labels to place at the given ticks locations. This argument can only be passed if ticks is passed as well.
Text properties can be used to control the appearance of the labels.
The list of xtick locations.
The list of xlabel Text objects.
Calling this function with no arguments (e.g. xticks()) is the pyplot equivalent of calling get_xticks and get_xticklabels on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_xticks and set_xticklabels on the current axes.
Secondary Axis
Table Demo
Rotating custom tick labels


Set the label for the y-axis.
The label text.
Spacing in points from the Axes bounding box including ticks and tick labels. If None, the previous value is left as is.
The label position. This is a high-level alternative for passing parameters y and horizontalalignment.
Text properties control the appearance of the label.
See also
Documents the properties supported by Text.
Scatter Symbol
Multiple subplots
Controlling style of text and labels using a dictionary
Pyplot Mathtext
Pyplot Simple
Pyplot Text
Solarized Light stylesheet
Findobj Demo
Table Demo
Custom scale
Basic Usage
Pyplot tutorial


Get or set the y-limits of the current axes.
Call signatures:
If you do not specify args, you can alternatively pass bottom or top as kwargs, i.e.:
Setting limits turns autoscaling off for the y-axis.
A tuple of the new y-axis limits.
Calling this function with no arguments (e.g. ylim()) is the pyplot equivalent of calling get_ylim on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_ylim on the current axes. All arguments are passed though.
Infinite lines
Pyplot Text
Frame grabbing
Interactive functions
Findobj Demo
Pyplot tutorial


Set the y-axis scale.
The axis scale type to apply.
Different keyword arguments are accepted, depending on the scale. See the respective class keyword arguments:
By default, Matplotlib supports the above mentioned scales. Additionally, custom scales may be registered using matplotlib.scale.register_scale. These scales can then also be used here.
Custom scale
Pyplot tutorial


Get or set the current tick locations and labels of the y-axis.
Pass no arguments to return the current values without modifying them.
The list of ytick locations. Passing an empty list removes all yticks.
The labels to place at the given ticks locations. This argument can only be passed if ticks is passed as well.
Text properties can be used to control the appearance of the labels.
The list of ytick locations.
The list of ylabel Text objects.
Calling this function with no arguments (e.g. yticks()) is the pyplot equivalent of calling get_yticks and get_yticklabels on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_yticks and set_yticklabels on the current axes.
Table Demo


Support for plotting vector fields.
Presently this contains Quiver and Barb. Quiver plots an arrow in the direction of the vector, with the size of the arrow related to the magnitude of the vector.
Barbs are like quiver in that they point along a vector, but the magnitude of the vector is given schematically by the presence of barbs or flags on the barb.
This will also become a home for things such as standard deviation ellipses, which can and will be derived very easily from the Quiver code.
Quiver(ax, *args[, scale, headwidth, ...])
Specialized PolyCollection for arrows.
QuiverKey(Q, X, Y, U, label, *[, angle, ...])
Labelled arrow for use as a quiver plot scale key.
Barbs(ax, *args[, pivot, length, barbcolor, ...])
Specialized PolyCollection for barbs.


Bases: matplotlib.collections.PolyCollection
Specialized PolyCollection for barbs.
The only API method is set_UVC(), which can be used to change the size, orientation, and color of the arrows. Locations are changed using the set_offsets() collection method. Possibly this method will be useful in animations.
There is one internal function _find_tails() which finds exactly what should be put on the barb given the vector magnitude. From there _make_barbs() is used to find the vertices of the polygon to represent the barb based on this information.
The constructor takes one required argument, an Axes instance, followed by the args and kwargs described by the following pyplot interface documentation:
Plot a 2D field of barbs.
Call signature:
Where X, Y define the barb locations, U, V define the barb directions, and C optionally sets the color.
All arguments may be 1D or 2D. U, V, C may be masked arrays, but masked X, Y are not supported at present.
Barbs are traditionally used in meteorology as a way to plot the speed and direction of wind observations, but can technically be used to plot any two dimensional vector quantity. As opposed to arrows, which give vector magnitude by the length of the arrow, the barbs give more quantitative information about the vector magnitude by putting slanted lines or a triangle for various increments in magnitude, as show schematically below:
The largest increment is given by a triangle (or "flag"). After those come full lines (barbs). The smallest increment is a half line. There is only, of course, ever at most 1 half line. If the magnitude is small and only needs a single half-line and no full lines or triangles, the half-line is offset from the end of the barb so that it can be easily distinguished from barbs with a single full line. The magnitude for the barb shown above would nominally be 65, using the standard increments of 50, 10, and 5.
See also https://en.wikipedia.org/wiki/Wind_barb.
The x and y coordinates of the barb locations. See pivot for how the barbs are drawn to the x, y positions.
If not given, they will be generated as a uniform integer meshgrid based on the dimensions of U and V.
If X and Y are 1D but U, V are 2D, X, Y are expanded to 2D using X, Y = np.meshgrid(X, Y). In this case len(X) and len(Y) must match the column and row dimensions of U and V.
The x and y components of the barb shaft.
Numeric data that defines the barb colors by colormapping via norm and cmap.
This does not support explicit colors. If you want to set colors directly, use barbcolor instead.
Length of the barb in points; the other parts of the barb are scaled against this.
The part of the arrow that is anchored to the X, Y grid. The barb rotates about this point. This can also be a number, which shifts the start of the barb that many points away from grid point.
The color of all parts of the barb except for the flags. This parameter is analogous to the edgecolor parameter for polygons, which can be used instead. However this parameter will override facecolor.
The color of any flags on the barb. This parameter is analogous to the facecolor parameter for polygons, which can be used instead. However, this parameter will override facecolor. If this is not set (and C has not either) then flagcolor will be set to match barbcolor so that the barb has a uniform color. If C has been set, flagcolor has no effect.
A dictionary of coefficients specifying the ratio of a given feature to the length of the barb. Only those values one wishes to override need to be included. These features include:
Whether the empty barbs (circles) that are drawn should be filled with the flag color. If they are not filled, the center is transparent.
Whether the vector magnitude should be rounded when allocating barb components. If True, the magnitude is rounded to the nearest multiple of the half-barb increment. If False, the magnitude is simply truncated to the next lowest multiple.
A dictionary of increments specifying values to associate with different parts of the barb. Only those values one wishes to override need to be included.
Whether the lines and flags should point opposite to normal. Normal behavior is for the barbs and lines to point right (comes from wind barbs having these features point towards low pressure in the Northern Hemisphere).
A single value is applied to all barbs. Individual barbs can be flipped by passing a bool array of the same size as U and V.
DATA_PARAMETER_PLACEHOLDER
The barbs can further be customized using PolyCollection keyword arguments:
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
Set multiple properties at once.
Supported properties are
Property
Description
UVC
unknown
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
sequence of pairs of floats
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
Set the offsets for the barb polygons. This saves the offsets passed in and masks them as appropriate for the existing U/V data.


Set multiple properties at once.
Supported properties are
Property
Description
UVC
unknown
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
sequence of pairs of floats
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float


Set the offsets for the barb polygons. This saves the offsets passed in and masks them as appropriate for the existing U/V data.


Bases: matplotlib.collections.PolyCollection
Specialized PolyCollection for arrows.
The only API method is set_UVC(), which can be used to change the size, orientation, and color of the arrows; their locations are fixed when the class is instantiated. Possibly this method will be useful in animations.
Much of the work in this class is done in the draw() method so that as much information as possible is available about the plot. In subsequent draw() calls, recalculation is limited to things that might have changed, so there should be no performance penalty from putting the calculations in the draw() method.
The constructor takes one required argument, an Axes instance, followed by the args and kwargs described by the following pyplot interface documentation:
Plot a 2D field of arrows.
Call signature:
X, Y define the arrow locations, U, V define the arrow directions, and C optionally sets the color.
Each arrow is internally represented by a filled polygon with a default edge linewidth of 0. As a result, an arrow is rather a filled area, not a line with a head, and PolyCollection properties like linewidth, linestyle, facecolor, etc. act accordingly.
Arrow size
The default settings auto-scales the length of the arrows to a reasonable size. To change this behavior see the scale and scale_units parameters.
Arrow shape
The defaults give a slightly swept-back arrow; to make the head a triangle, make headaxislength the same as headlength. To make the arrow more pointed, reduce headwidth or increase headlength and headaxislength. To make the head smaller relative to the shaft, scale down all the head parameters. You will probably do best to leave minshaft alone.
Arrow outline
linewidths and edgecolors can be used to customize the arrow outlines.
The x and y coordinates of the arrow locations.
If not given, they will be generated as a uniform integer meshgrid based on the dimensions of U and V.
If X and Y are 1D but U, V are 2D, X, Y are expanded to 2D using X, Y = np.meshgrid(X, Y). In this case len(X) and len(Y) must match the column and row dimensions of U and V.
The x and y direction components of the arrow vectors.
They must have the same number of elements, matching the number of arrow locations. U and V may be masked. Only locations unmasked in U, V, and C will be drawn.
Numeric data that defines the arrow colors by colormapping via norm and cmap.
This does not support explicit colors. If you want to set colors directly, use color instead. The size of C must match the number of arrow locations.
The arrow dimensions (except for length) are measured in multiples of this unit.
The following values are supported:
The arrows scale differently depending on the units. For 'x' or 'y', the arrows get larger as one zooms in; for other units, the arrow size is independent of the zoom state. For 'width or 'height', the arrow size increases with the width and height of the axes, respectively, when the window is resized; for 'dots' or 'inches', resizing does not change the arrows.
Method for determining the angle of the arrows.
'uv': The arrow axis aspect ratio is 1 so that if U == V the orientation of the arrow on the plot is 45 degrees counter-clockwise from the horizontal axis (positive to the right).
Use this if the arrows symbolize a quantity that is not based on X, Y data coordinates.
Alternatively, arbitrary angles may be specified explicitly as an array of values in degrees, counter-clockwise from the horizontal axis.
In this case U, V is only used to determine the length of the arrows.
Note: inverting a data axis will correspondingly invert the arrows only with angles='xy'.
Number of data units per arrow length unit, e.g., m/s per plot width; a smaller scale parameter makes the arrow longer. Default is None.
If None, a simple autoscaling algorithm is used, based on the average vector length and the number of vectors. The arrow length unit is given by the scale_units parameter.
If the scale kwarg is None, the arrow length unit. Default is None.
e.g. scale_units is 'inches', scale is 2.0, and (u, v) = (1, 0), then the vector will be 0.5 inches long.
If scale_units is 'width' or 'height', then the vector will be half the width/height of the axes.
If scale_units is 'x' then the vector will be 0.5 x-axis units. To plot vectors in the x-y plane, with u and v having the same units as x and y, use angles='xy', scale_units='xy', scale=1.
Shaft width in arrow units; default depends on choice of units, above, and number of vectors; a typical starting value is about 0.005 times the width of the plot.
Head width as multiple of shaft width.
Head length as multiple of shaft width.
Head length at shaft intersection.
Length below which arrow scales, in units of head length. Do not set this to less than 1, or small arrows will look terrible!
Minimum length as a multiple of shaft width; if an arrow length is less than this, plot a dot (hexagon) of this diameter instead.
The part of the arrow that is anchored to the X, Y grid. The arrow rotates about this point.
'mid' is a synonym for 'middle'.
Explicit color(s) for the arrows. If C has been set, color has no effect.
This is a synonym for the PolyCollection facecolor parameter.
DATA_PARAMETER_PLACEHOLDER
All other keyword arguments are passed on to PolyCollection:
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
See also
Add a key to a quiver plot.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible returns False).
This method is overridden in the Artist subclasses.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.
Note: relim will not see collections even if the collection was added to the axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Set multiple properties at once.
Supported properties are
Property
Description
UVC
unknown
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float
Advanced quiver and quiverkey functions
Quiver Simple Demo


Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible returns False).
This method is overridden in the Artist subclasses.


Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.
Note: relim will not see collections even if the collection was added to the axes with autolim = True.
Note: there is no support for removing the artist's legend entry.


Set multiple properties at once.
Supported properties are
Property
Description
UVC
unknown
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
array-like or scalar or None
animated
bool
antialiased or aa or antialiaseds
bool or list of bools
array
array-like or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clim
(vmin: float, vmax: float)
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
cmap
Colormap or str or None
color
color or list of rgba tuples
edgecolor or ec or edgecolors
color or list of colors or 'face'
facecolor or facecolors or fc
color or list of colors
figure
Figure
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or dashes or linestyles or ls
str or tuple or list thereof
linewidth or linewidths or lw
float or list of floats
norm
Normalize or None
offset_transform
Transform
offsets
(N, 2) or (2,) array-like
path_effects
AbstractPathEffect
paths
list of array-like
picker
None or bool or float or callable
pickradius
float
rasterized
bool
sizes
ndarray or None
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
urls
list of str or None
verts
list of array-like
verts_and_codes
unknown
visible
bool
zorder
float


Bases: matplotlib.artist.Artist
Labelled arrow for use as a quiver plot scale key.
Add a key to a quiver plot.
The positioning of the key depends on X, Y, coordinates, and labelpos. If labelpos is 'N' or 'S', X, Y give the position of the middle of the key arrow. If labelpos is 'E', X, Y positions the head, and if labelpos is 'W', X, Y positions the tail; in either of these two cases, X, Y is somewhere in the middle of the arrow+label key object.
A Quiver object as returned by a call to quiver().
The location of the key.
The length of the key.
The key label (e.g., length and units of the key).
The angle of the key arrow, in degrees anti-clockwise from the x-axis.
Coordinate system and units for X, Y: 'axes' and 'figure' are normalized coordinate systems with (0, 0) in the lower left and (1, 1) in the upper right; 'data' are the axes data coordinates (used for the locations of the vectors in the quiver plot itself); 'inches' is position in the figure in inches, with (0, 0) at the lower left corner.
Overrides face and edge colors from Q.
Position the label above, below, to the right, to the left of the arrow, respectively.
Distance in inches between the arrow and the label.
Label color.
A dictionary with keyword arguments accepted by the FontProperties initializer: family, style, variant, size, weight.
Any additional keyword arguments are used to override vector properties taken from Q.
Test whether the artist contains the mouse event.
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible returns False).
This method is overridden in the Artist subclasses.
Remove the artist from the figure if possible.
The effect will not be visible until the figure is redrawn, e.g., with FigureCanvasBase.draw_idle. Call relim to update the axes limits if desired.
Note: relim will not see collections even if the collection was added to the axes with autolim = True.
Note: there is no support for removing the artist's legend entry.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
figure
unknown
gid
str
in_layout
bool
label
object
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
Set the Figure instance the artist belongs to.
Advanced quiver and quiverkey functions


Test whether the artist contains the mouse event.
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
figure
unknown
gid
str
in_layout
bool
label
object
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float


Set the Figure instance the artist belongs to.


Set the current rcParams. group is the grouping for the rc, e.g., for lines.linewidth the group is lines, for axes.facecolor, the group is axes, and so on. Group may also be a list or tuple of group names, e.g., (xtick, ytick). kwargs is a dictionary attribute name/value pairs, e.g.,:
sets the current rcParams and is equivalent to:
The following aliases are available to save typing for interactive users:
Alias
Property
'lw'
'linewidth'
'ls'
'linestyle'
'c'
'color'
'fc'
'facecolor'
'ec'
'edgecolor'
'mew'
'markeredgewidth'
'aa'
'antialiased'
Thus you could abbreviate the above call as:
Note you can use python's kwargs dictionary facility to store dictionaries of default parameters. e.g., you can customize the font rc as follows:
This enables you to easily switch between several configurations. Use matplotlib.style.use('default') or rcdefaults() to restore the default rcParams after changes.
Similar functionality is available by using the normal dict interface, i.e. rcParams.update({"lines.linewidth": 2, ...}) (but rcParams.update does not support abbreviations or grouping).


Return a context manager for temporarily changing rcParams.
The rcParams to temporarily set.
A file with Matplotlib rc settings. If both fname and rc are given, settings from rc take precedence.
See also
Passing explicit values via a dict:
Loading settings from a file:


Update rcParams from file.
Style-blacklisted rcParams (defined in matplotlib.style.core.STYLE_BLACKLIST) are not updated.
A file with Matplotlib rc settings.
If True, initialize with default parameters before updating with those in the given file. If False, the current configuration persists and only the parameters specified in the file are updated.


Restore the rcParams from the original rc file loaded by Matplotlib.
Style-blacklisted rcParams (defined in matplotlib.style.core.STYLE_BLACKLIST) are not updated.


Construct a RcParams instance from the default Matplotlib rc file.


Construct a RcParams from file fname.
A file with Matplotlib rc settings.
If True, raise an error when the parser fails to convert a parameter.
If True, initialize with default parameters before updating with those in the given file. If False, the configuration class only contains the parameters specified in the file. (Useful for updating dicts.)


Restore the rcParams from Matplotlib's internal default style.
Style-blacklisted rcParams (defined in matplotlib.style.core.STYLE_BLACKLIST) are not updated.
See also
Restore the rcParams from the rc file originally loaded by Matplotlib.
Use a specific style file. Call style.use('default') to restore the default style.


An instance of RcParams for handling default Matplotlib values.


A dictionary object including validation.
Validating functions are defined and associated with rc parameters in matplotlib.rcsetup.
The list of rcParams is:
See also
Return the subset of this RcParams dictionary whose keys match, using re.search(), the given pattern.
Note
Changes to the returned dictionary are not propagated to the parent RcParams dictionary.


Return the subset of this RcParams dictionary whose keys match, using re.search(), the given pattern.
Note
Changes to the returned dictionary are not propagated to the parent RcParams dictionary.


The rcsetup module contains the validation code for customization using Matplotlib's rc settings.
Each rc setting is assigned a function used to validate any attempted changes to that setting. The validation functions are defined in the rcsetup module, and are used to construct the rcParams global object which stores the settings and is referenced throughout Matplotlib.
The default values of the rc settings are set in the default matplotlibrc file. Any additions or deletions to the parameter set listed here should also be propagated to the matplotlibrc.template in Matplotlib's root source directory.
Bases: object
valid is a list of legal strings.
Create a Cycler object much like cycler.cycler(), but includes input validation.
Call signatures:
Form 1 copies a given Cycler object.
Form 2 creates a Cycler which cycles over one or more properties simultaneously. If multiple properties are given, their value lists must have the same length.
Form 3 creates a Cycler for a single property. This form exists for compatibility with the original cycler. Its use is discouraged in favor of the kwarg form, i.e. cycler(label=values).
Copy constructor for Cycler.
The property key. Must be a valid Artist property. For example, 'color' or 'linestyle'. Aliases are allowed, such as 'c' for 'color' and 'lw' for 'linewidth'.
Finite-length iterable of the property values. These values are validated and will raise a ValueError if invalid.
A new Cycler for the given properties.
Creating a cycler for a single property:
Creating a cycler for simultaneously cycling over multiple properties (e.g. red circle, green plus, blue cross):
Convert b to bool or raise.
Return a valid color arg.
Return a valid color arg.
return a list of colorspecs
Return a Cycler object from a string repr or the object itself.
return a list of floats
Confirm s is string 'figure' or convert s to float or raise.
return a list of floats
Confirm that this is a Postscript or PDF font type that we know how to convert to.
Validate a hatch pattern. A hatch pattern string can have any sequence of the following characters: \ / | - + * . x o O.
Validate a hatch pattern. A hatch pattern string can have any sequence of the following characters: \ / | - + * . x o O.
Validate the markevery property of a Line2D object.
Validate the markevery property of a Line2D object.
return a list of strings


Create a Cycler object much like cycler.cycler(), but includes input validation.
Call signatures:
Form 1 copies a given Cycler object.
Form 2 creates a Cycler which cycles over one or more properties simultaneously. If multiple properties are given, their value lists must have the same length.
Form 3 creates a Cycler for a single property. This form exists for compatibility with the original cycler. Its use is discouraged in favor of the kwarg form, i.e. cycler(label=values).
Copy constructor for Cycler.
The property key. Must be a valid Artist property. For example, 'color' or 'linestyle'. Aliases are allowed, such as 'c' for 'color' and 'lw' for 'linewidth'.
Finite-length iterable of the property values. These values are validated and will raise a ValueError if invalid.
A new Cycler for the given properties.
Creating a cycler for a single property:
Creating a cycler for simultaneously cycling over multiple properties (e.g. red circle, green plus, blue cross):


Return a Cycler object from a string repr or the object itself.


Confirm s is string 'figure' or convert s to float or raise.


Confirm that this is a Postscript or PDF font type that we know how to convert to.


Validate a hatch pattern. A hatch pattern string can have any sequence of the following characters: \ / | - + * . x o O.


Validate the markevery property of a Line2D object.


Bases: object
valid is a list of legal strings.


Module for creating Sankey diagrams using Matplotlib.
Bases: object
Sankey diagram.
Sankey diagrams are a specific type of flow diagram, in which the width of the arrows is shown proportionally to the flow quantity. They are typically used to visualize energy or material or cost transfers between processes. Wikipedia (6/1/2011)
Create a new Sankey instance.
The optional arguments listed below are applied to all subdiagrams so that there is consistent alignment and formatting.
In order to draw a complex Sankey diagram, create an instance of Sankey by calling it without any kwargs:
Then add simple Sankey sub-diagrams:
Finally, create the full diagram:
Or, instead, simply daisy-chain those calls:
Axes onto which the data should be plotted. If ax isn't provided, new Axes will be created.
Scaling factor for the flows. scale sizes the width of the paths in order to maintain proper layout. The same scale is applied to all subdiagrams. The value should be chosen such that the product of the scale and the sum of the inputs is approximately 1.0 (and the product of the scale and the sum of the outputs is approximately -1.0).
The physical unit associated with the flow quantities. If unit is None, then none of the quantities are labeled.
A Python number formatting string or callable used to label the flows with their quantities (i.e., a number times a unit, where the unit is given). If a format string is given, the label will be format % quantity. If a callable is given, it will be called with quantity as an argument.
Space between paths that break in/break away to/from the top or bottom.
Inner radius of the vertical paths.
Size of the shoulders of output arrows.
Text offset (from the dip or tip of the arrow).
Angle, in degrees, of the arrow heads (and negative of the angle of the tails).
Minimum space between Sankey outlines and the edge of the plot area.
Acceptable maximum of the magnitude of the sum of flows. The magnitude of the sum of connected flows cannot be greater than tolerance.
Any additional keyword arguments will be passed to add(), which will create the first subdiagram.
See also
(Source code)
(png, pdf)
(png, pdf)
(png, pdf)
Add a simple Sankey diagram with flows at the same hierarchical level.
Label to be placed at the center of the diagram. Note that label (not patchlabel) can be passed as keyword argument to create an entry in the legend.
Array of flow values. By convention, inputs are positive and outputs are negative.
Flows are placed along the top of the diagram from the inside out in order of their index within flows. They are placed along the sides of the diagram from the top down and along the bottom from the outside in.
If the sum of the inputs and outputs is nonzero, the discrepancy will appear as a cubic Bezier curve along the top and bottom edges of the trunk.
List of orientations of the flows (or a single orientation to be used for all flows). Valid values are 0 (inputs from the left, outputs to the right), 1 (from and to the top) or -1 (from and to the bottom).
List of labels for the flows (or a single label to be used for all flows). Each label may be None (no label), or a labeling string. If an entry is a (possibly empty) string, then the quantity for the corresponding flow will be shown below the string. However, if the unit of the main diagram is None, then quantities are never shown, regardless of the value of this argument.
Length between the bases of the input and output groups (in data-space units).
List of lengths of the vertical arrows before break-in or after break-away. If a single value is given, then it will be applied to the first (inside) paths on the top and bottom, and the length of all other arrows will be justified accordingly. The pathlengths are not applied to the horizontal inputs and outputs.
Index of the prior diagram to which this diagram should be connected.
A (prior, this) tuple indexing the flow of the prior diagram and the flow of this diagram which should be connected. If this is the first diagram or prior is None, connect will be ignored.
Angle of rotation of the diagram in degrees. The interpretation of the orientations argument will be rotated accordingly (e.g., if rotation == 90, an orientations entry of 1 means to/from the left). rotation is ignored if this diagram is connected to an existing one (using prior and connect).
The current Sankey instance.
Additional keyword arguments set matplotlib.patches.PathPatch properties, listed below. For example, one may want to use fill=False or label="A legend entry".
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
unknown
animated
bool
antialiased or aa
bool or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color
color
edgecolor or ec
color or None
facecolor or fc
color or None
figure
Figure
fill
bool
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
See also
Adjust the axes and return a list of information about the Sankey subdiagram(s).
Return value is a list of subdiagrams represented with the following fields:
Field
Description
patch
Sankey outline (an instance of PathPatch)
flows
values of the flows (positive for input, negative for output)
angles
list of angles of the arrows [deg/90] For example, if the diagram has not been rotated, an input to the top side will have an angle of 3 (DOWN), and an output from the top side will have an angle of 1 (UP). If a flow has been skipped (because its magnitude is less than tolerance), then its angle will be None.
tips
array in which each row is an [x, y] pair indicating the positions of the tips (or "dips") of the flow paths If the magnitude of a flow is less the tolerance for the instance of Sankey, the flow is skipped and its tip will be at the center of the diagram.
text
Text instance for the label of the diagram
texts
list of Text instances for the labels of flows
See also


Bases: object
Sankey diagram.
Sankey diagrams are a specific type of flow diagram, in which the width of the arrows is shown proportionally to the flow quantity. They are typically used to visualize energy or material or cost transfers between processes. Wikipedia (6/1/2011)
Create a new Sankey instance.
The optional arguments listed below are applied to all subdiagrams so that there is consistent alignment and formatting.
In order to draw a complex Sankey diagram, create an instance of Sankey by calling it without any kwargs:
Then add simple Sankey sub-diagrams:
Finally, create the full diagram:
Or, instead, simply daisy-chain those calls:
Axes onto which the data should be plotted. If ax isn't provided, new Axes will be created.
Scaling factor for the flows. scale sizes the width of the paths in order to maintain proper layout. The same scale is applied to all subdiagrams. The value should be chosen such that the product of the scale and the sum of the inputs is approximately 1.0 (and the product of the scale and the sum of the outputs is approximately -1.0).
The physical unit associated with the flow quantities. If unit is None, then none of the quantities are labeled.
A Python number formatting string or callable used to label the flows with their quantities (i.e., a number times a unit, where the unit is given). If a format string is given, the label will be format % quantity. If a callable is given, it will be called with quantity as an argument.
Space between paths that break in/break away to/from the top or bottom.
Inner radius of the vertical paths.
Size of the shoulders of output arrows.
Text offset (from the dip or tip of the arrow).
Angle, in degrees, of the arrow heads (and negative of the angle of the tails).
Minimum space between Sankey outlines and the edge of the plot area.
Acceptable maximum of the magnitude of the sum of flows. The magnitude of the sum of connected flows cannot be greater than tolerance.
Any additional keyword arguments will be passed to add(), which will create the first subdiagram.
See also
(Source code)
(png, pdf)
(png, pdf)
(png, pdf)
Add a simple Sankey diagram with flows at the same hierarchical level.
Label to be placed at the center of the diagram. Note that label (not patchlabel) can be passed as keyword argument to create an entry in the legend.
Array of flow values. By convention, inputs are positive and outputs are negative.
Flows are placed along the top of the diagram from the inside out in order of their index within flows. They are placed along the sides of the diagram from the top down and along the bottom from the outside in.
If the sum of the inputs and outputs is nonzero, the discrepancy will appear as a cubic Bezier curve along the top and bottom edges of the trunk.
List of orientations of the flows (or a single orientation to be used for all flows). Valid values are 0 (inputs from the left, outputs to the right), 1 (from and to the top) or -1 (from and to the bottom).
List of labels for the flows (or a single label to be used for all flows). Each label may be None (no label), or a labeling string. If an entry is a (possibly empty) string, then the quantity for the corresponding flow will be shown below the string. However, if the unit of the main diagram is None, then quantities are never shown, regardless of the value of this argument.
Length between the bases of the input and output groups (in data-space units).
List of lengths of the vertical arrows before break-in or after break-away. If a single value is given, then it will be applied to the first (inside) paths on the top and bottom, and the length of all other arrows will be justified accordingly. The pathlengths are not applied to the horizontal inputs and outputs.
Index of the prior diagram to which this diagram should be connected.
A (prior, this) tuple indexing the flow of the prior diagram and the flow of this diagram which should be connected. If this is the first diagram or prior is None, connect will be ignored.
Angle of rotation of the diagram in degrees. The interpretation of the orientations argument will be rotated accordingly (e.g., if rotation == 90, an orientations entry of 1 means to/from the left). rotation is ignored if this diagram is connected to an existing one (using prior and connect).
The current Sankey instance.
Additional keyword arguments set matplotlib.patches.PathPatch properties, listed below. For example, one may want to use fill=False or label="A legend entry".
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
unknown
animated
bool
antialiased or aa
bool or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color
color
edgecolor or ec
color or None
facecolor or fc
color or None
figure
Figure
fill
bool
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
See also
Adjust the axes and return a list of information about the Sankey subdiagram(s).
Return value is a list of subdiagrams represented with the following fields:
Field
Description
patch
Sankey outline (an instance of PathPatch)
flows
values of the flows (positive for input, negative for output)
angles
list of angles of the arrows [deg/90] For example, if the diagram has not been rotated, an input to the top side will have an angle of 3 (DOWN), and an output from the top side will have an angle of 1 (UP). If a flow has been skipped (because its magnitude is less than tolerance), then its angle will be None.
tips
array in which each row is an [x, y] pair indicating the positions of the tips (or "dips") of the flow paths If the magnitude of a flow is less the tolerance for the instance of Sankey, the flow is skipped and its tip will be at the center of the diagram.
text
Text instance for the label of the diagram
texts
list of Text instances for the labels of flows
See also


Add a simple Sankey diagram with flows at the same hierarchical level.
Label to be placed at the center of the diagram. Note that label (not patchlabel) can be passed as keyword argument to create an entry in the legend.
Array of flow values. By convention, inputs are positive and outputs are negative.
Flows are placed along the top of the diagram from the inside out in order of their index within flows. They are placed along the sides of the diagram from the top down and along the bottom from the outside in.
If the sum of the inputs and outputs is nonzero, the discrepancy will appear as a cubic Bezier curve along the top and bottom edges of the trunk.
List of orientations of the flows (or a single orientation to be used for all flows). Valid values are 0 (inputs from the left, outputs to the right), 1 (from and to the top) or -1 (from and to the bottom).
List of labels for the flows (or a single label to be used for all flows). Each label may be None (no label), or a labeling string. If an entry is a (possibly empty) string, then the quantity for the corresponding flow will be shown below the string. However, if the unit of the main diagram is None, then quantities are never shown, regardless of the value of this argument.
Length between the bases of the input and output groups (in data-space units).
List of lengths of the vertical arrows before break-in or after break-away. If a single value is given, then it will be applied to the first (inside) paths on the top and bottom, and the length of all other arrows will be justified accordingly. The pathlengths are not applied to the horizontal inputs and outputs.
Index of the prior diagram to which this diagram should be connected.
A (prior, this) tuple indexing the flow of the prior diagram and the flow of this diagram which should be connected. If this is the first diagram or prior is None, connect will be ignored.
Angle of rotation of the diagram in degrees. The interpretation of the orientations argument will be rotated accordingly (e.g., if rotation == 90, an orientations entry of 1 means to/from the left). rotation is ignored if this diagram is connected to an existing one (using prior and connect).
The current Sankey instance.
Additional keyword arguments set matplotlib.patches.PathPatch properties, listed below. For example, one may want to use fill=False or label="A legend entry".
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
unknown
animated
bool
antialiased or aa
bool or None
capstyle
CapStyle or {'butt', 'projecting', 'round'}
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color
color
edgecolor or ec
color or None
facecolor or fc
color or None
figure
Figure
fill
bool
gid
str
hatch
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
in_layout
bool
joinstyle
JoinStyle or {'miter', 'round', 'bevel'}
label
object
linestyle or ls
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
linewidth or lw
float or None
path_effects
AbstractPathEffect
picker
None or bool or float or callable
rasterized
bool
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
transform
Transform
url
str
visible
bool
zorder
float
See also


Adjust the axes and return a list of information about the Sankey subdiagram(s).
Return value is a list of subdiagrams represented with the following fields:
Field
Description
patch
Sankey outline (an instance of PathPatch)
flows
values of the flows (positive for input, negative for output)
angles
list of angles of the arrows [deg/90] For example, if the diagram has not been rotated, an input to the top side will have an angle of 3 (DOWN), and an output from the top side will have an angle of 1 (UP). If a flow has been skipped (because its magnitude is less than tolerance), then its angle will be None.
tips
array in which each row is an [x, y] pair indicating the positions of the tips (or "dips") of the flow paths If the magnitude of a flow is less the tolerance for the instance of Sankey, the flow is skipped and its tip will be at the center of the diagram.
text
Text instance for the label of the diagram
texts
list of Text instances for the labels of flows
See also