matplotlib

Table Of Contents

Previous topic

matplotlib dates

Next topic

matplotlib font_manager

This Page

matplotlib figure

matplotlib.figure

The figure module provides the top-level Artist, the Figure, which contains all the plot elements. The following classes are defined

SubplotParams
control the default spacing of the subplots
Figure
top level container for all plot elements
class matplotlib.figure.Figure(figsize=None, dpi=None, facecolor=None, edgecolor=None, linewidth=1.0, frameon=True, subplotpars=None)

Bases: matplotlib.artist.Artist

The Figure instance supports callbacks through a callbacks attribute which is a matplotlib.cbook.CallbackRegistry instance. The events you can connect to are ‘dpi_changed’, and the callback will be called with func(fig) where fig is the Figure instance.

The figure patch is drawn by a the attribute

patch
a matplotlib.patches.Rectangle instance
suppressComposite
for multiple figure images, the figure will make composite images depending on the renderer option_image_nocomposite function. If suppressComposite is True|False, this will override the renderer
figsize
w,h tuple in inches
dpi
dots per inch
facecolor
the figure patch facecolor; defaults to rc figure.facecolor
edgecolor
the figure patch edge color; defaults to rc figure.edgecolor
linewidth
the figure patch edge linewidth; the default linewidth of the frame
frameon
if False, suppress drawing the figure frame
subplotpars
a SubplotParams instance, defaults to rc
add_axes(*args, **kwargs)

Add an a axes with axes rect [left, bottom, width, height] where all quantities are in fractions of figure width and height. kwargs are legal Axes kwargs plus projection which sets the projection type of the axes. (For backward compatibility, polar=True may also be provided, which is equivalent to projection='polar'). Valid values for projection are: [‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’]. Some of these projections support additional kwargs, which may be provided to add_axes():

rect = l,b,w,h
fig.add_axes(rect)
fig.add_axes(rect, frameon=False, axisbg='g')
fig.add_axes(rect, polar=True)
fig.add_axes(rect, projection='polar')
fig.add_axes(ax)   # add an Axes instance

If the figure already has an axes with the same parameters, then it will simply make that axes current and return it. If you do not want this behavior, eg. you want to force the creation of a new axes, you must use a unique set of args and kwargs. The axes label attribute has been exposed for this purpose. Eg., if you want two axes that are otherwise identical to be added to the figure, make sure you give them unique labels:

fig.add_axes(rect, label='axes1')
fig.add_axes(rect, label='axes2')

The Axes instance will be returned.

The following kwargs are supported:

Property Description
adjustable [ ‘box’ | ‘datalim’ | ‘box-forced’]
agg_filter unknown
alpha float (0.0 transparent through 1.0 opaque)
anchor unknown
animated [True | False]
aspect unknown
autoscale_on unknown
autoscalex_on unknown
autoscaley_on unknown
axes an Axes instance
axes_locator unknown
axis_bgcolor any matplotlib color - see colors()
axis_off unknown
axis_on unknown
axisbelow [ True | False ]
clip_box a matplotlib.transforms.Bbox instance
clip_on [True | False]
clip_path [ (Path, Transform) | Patch | None ]
color_cycle unknown
contains a callable function
cursor_props a (float, color) tuple
figure unknown
frame_on [ True | False ]
gid an id string
label any string
lod [True | False]
navigate [ True | False ]
navigate_mode unknown
picker [None|float|boolean|callable]
position unknown
rasterization_zorder unknown
rasterized [True | False | None]
snap unknown
title str
transform Transform instance
url a url string
visible [True | False]
xbound unknown
xlabel str
xlim len(2) sequence of floats
xmargin unknown
xscale [‘linear’ | ‘log’ | ‘symlog’]
xticklabels sequence of strings
xticks sequence of floats
ybound unknown
ylabel str
ylim len(2) sequence of floats
ymargin unknown
yscale [‘linear’ | ‘log’ | ‘symlog’]
yticklabels sequence of strings
yticks sequence of floats
zorder any number
add_axobserver(func)

whenever the axes state change, func(self) will be called

add_subplot(*args, **kwargs)

Add a subplot. Examples:

fig.add_subplot(111) fig.add_subplot(1,1,1) # equivalent but more general fig.add_subplot(212, axisbg=’r’) # add subplot with red background fig.add_subplot(111, polar=True) # add a polar subplot fig.add_subplot(sub) # add Subplot instance sub

kwargs are legal matplotlib.axes.Axes kwargs plus projection, which chooses a projection type for the axes. (For backward compatibility, polar=True may also be provided, which is equivalent to projection=’polar’). Valid values for projection are: [‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’]. Some of these projections support additional kwargs, which may be provided to add_axes().

The Axes instance will be returned.

If the figure already has a subplot with key (args, kwargs) then it will simply make that subplot current and return it.

The following kwargs are supported:

Property Description
adjustable [ ‘box’ | ‘datalim’ | ‘box-forced’]
agg_filter unknown
alpha float (0.0 transparent through 1.0 opaque)
anchor unknown
animated [True | False]
aspect unknown
autoscale_on unknown
autoscalex_on unknown
autoscaley_on unknown
axes an Axes instance
axes_locator unknown
axis_bgcolor any matplotlib color - see colors()
axis_off unknown
axis_on unknown
axisbelow [ True | False ]
clip_box a matplotlib.transforms.Bbox instance
clip_on [True | False]
clip_path [ (Path, Transform) | Patch | None ]
color_cycle unknown
contains a callable function
cursor_props a (float, color) tuple
figure unknown
frame_on [ True | False ]
gid an id string
label any string
lod [True | False]
navigate [ True | False ]
navigate_mode unknown
picker [None|float|boolean|callable]
position unknown
rasterization_zorder unknown
rasterized [True | False | None]
snap unknown
title str
transform Transform instance
url a url string
visible [True | False]
xbound unknown
xlabel str
xlim len(2) sequence of floats
xmargin unknown
xscale [‘linear’ | ‘log’ | ‘symlog’]
xticklabels sequence of strings
xticks sequence of floats
ybound unknown
ylabel str
ylim len(2) sequence of floats
ymargin unknown
yscale [‘linear’ | ‘log’ | ‘symlog’]
yticklabels sequence of strings
yticks sequence of floats
zorder any number
autofmt_xdate(bottom=0.20000000000000001, rotation=30, ha='right')

Date ticklabels often overlap, so it is useful to rotate them and right align them. Also, a common use case is a number of subplots with shared xaxes where the x-axis is date data. The ticklabels are often long, and it helps to rotate them on the bottom subplot and turn them off on other subplots, as well as turn off xlabels.

bottom
the bottom of the subplots for subplots_adjust()
rotation
the rotation of the xtick labels
ha
the horizontal alignment of the xticklabels
clear()

Clear the figure – synonym for fig.clf

clf(keep_observers=False)

Clear the figure.

Set keep_observers to True if, for example, a gui widget is tracking the axes in the figure.

colorbar(mappable, cax=None, ax=None, **kw)

Create a colorbar for a ScalarMappable instance.

Documentation for the pylab thin wrapper:

Add a colorbar to a plot.

Function signatures for the pyplot interface; all but the first are also method signatures for the colorbar() method:

colorbar(**kwargs)
colorbar(mappable, **kwargs)
colorbar(mappable, cax=cax, **kwargs)
colorbar(mappable, ax=ax, **kwargs)

arguments:

mappable
the Image, ContourSet, etc. to which the colorbar applies; this argument is mandatory for the colorbar() method but optional for the colorbar() function, which sets the default to the current image.

keyword arguments:

cax
None | axes object into which the colorbar will be drawn
ax
None | parent axes object from which space for a new colorbar axes will be stolen

Additional keyword arguments are of two kinds:

axes properties:

Property Description
orientation vertical or horizontal
fraction 0.15; fraction of original axes to use for colorbar
pad 0.05 if vertical, 0.15 if horizontal; fraction of original axes between colorbar and new image axes
shrink 1.0; fraction by which to shrink the colorbar
aspect 20; ratio of long to short dimensions

colorbar properties:

Property Description
extend [ ‘neither’ | ‘both’ | ‘min’ | ‘max’ ] If not ‘neither’, make pointed end(s) for out-of- range values. These are set for a given colormap using the colormap set_under and set_over methods.
spacing [ ‘uniform’ | ‘proportional’ ] Uniform spacing gives each discrete color the same space; proportional makes the space proportional to the data interval.
ticks [ None | list of ticks | Locator object ] If None, ticks are determined automatically from the input.
format [ None | format string | Formatter object ] If None, the ScalarFormatter is used. If a format string is given, e.g. ‘%.3f’, that is used. An alternative Formatter object may be given instead.
drawedges [ False | True ] If true, draw lines at color boundaries.

The following will probably be useful only in the context of indexed colors (that is, when the mappable has norm=NoNorm()), or other unusual circumstances.

Property Description
boundaries None or a sequence
values None or a sequence which must be of length 1 less than the sequence of boundaries. For each region delimited by adjacent entries in boundaries, the color mapped to the corresponding value in values will be used.

If mappable is a ContourSet, its extend kwarg is included automatically.

Note that the shrink kwarg provides a simple way to keep a vertical colorbar, for example, from being taller than the axes of the mappable to which the colorbar is attached; but it is a manual method requiring some trial and error. If the colorbar is too tall (or a horizontal colorbar is too wide) use a smaller value of shrink.

For more precise control, you can manually specify the positions of the axes objects in which the mappable and the colorbar are drawn. In this case, do not use any of the axes properties kwargs.

returns:
Colorbar instance; see also its base class, ColorbarBase. Call the set_label() method to label the colorbar.
contains(mouseevent)

Test whether the mouse event occurred on the figure.

Returns True,{}

delaxes(a)

remove a from the figure and update the current axes

dpi
draw(artist, renderer, *args, **kwargs)

Render the figure using matplotlib.backend_bases.RendererBase instance renderer

draw_artist(a)

draw matplotlib.artist.Artist instance a only – this is available only after the figure is drawn

figimage(X, xo=0, yo=0, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, origin=None, **kwargs)

call signatures:

figimage(X, **kwargs)

adds a non-resampled array X to the figure.

figimage(X, xo, yo)

with pixel offsets xo, yo,

X must be a float array:

  • If X is MxN, assume luminance (grayscale)
  • If X is MxNx3, assume RGB
  • If X is MxNx4, assume RGBA

Optional keyword arguments:

Keyword Description
xo or yo An integer, the x and y image offset in pixels
cmap a matplotlib.cm.ColorMap instance, eg cm.jet. If None, default to the rc image.cmap value
norm a matplotlib.colors.Normalize instance. The default is normalization(). This scales luminance -> 0-1
vmin|vmax are used to scale a luminance image to 0-1. If either is None, the min and max of the luminance values will be used. Note if you pass a norm instance, the settings for vmin and vmax will be ignored.
alpha the alpha blending value, default is None
origin [ ‘upper’ | ‘lower’ ] Indicates where the [0,0] index of the array is in the upper left or lower left corner of the axes. Defaults to the rc image.origin value

figimage complements the axes image (imshow()) which will be resampled to fit the current axes. If you want a resampled image to fill the entire figure, you can define an Axes with size [0,1,0,1].

An matplotlib.image.FigureImage instance is returned.

[source code, hires.png, pdf]

../_images/figimage_demo.png

Additional kwargs are Artist kwargs passed on to FigureImage

gca(**kwargs)

Return the current axes, creating one if necessary

The following kwargs are supported

Property Description
adjustable [ ‘box’ | ‘datalim’ | ‘box-forced’]
agg_filter unknown
alpha float (0.0 transparent through 1.0 opaque)
anchor unknown
animated [True | False]
aspect unknown
autoscale_on unknown
autoscalex_on unknown
autoscaley_on unknown
axes an Axes instance
axes_locator unknown
axis_bgcolor any matplotlib color - see colors()
axis_off unknown
axis_on unknown
axisbelow [ True | False ]
clip_box a matplotlib.transforms.Bbox instance
clip_on [True | False]
clip_path [ (Path, Transform) | Patch | None ]
color_cycle unknown
contains a callable function
cursor_props a (float, color) tuple
figure unknown
frame_on [ True | False ]
gid an id string
label any string
lod [True | False]
navigate [ True | False ]
navigate_mode unknown
picker [None|float|boolean|callable]
position unknown
rasterization_zorder unknown
rasterized [True | False | None]
snap unknown
title str
transform Transform instance
url a url string
visible [True | False]
xbound unknown
xlabel str
xlim len(2) sequence of floats
xmargin unknown
xscale [‘linear’ | ‘log’ | ‘symlog’]
xticklabels sequence of strings
xticks sequence of floats
ybound unknown
ylabel str
ylim len(2) sequence of floats
ymargin unknown
yscale [‘linear’ | ‘log’ | ‘symlog’]
yticklabels sequence of strings
yticks sequence of floats
zorder any number
get_axes()
get_children()

get a list of artists contained in the figure

get_dpi()

Return the dpi as a float

get_edgecolor()

Get the edge color of the Figure rectangle

get_facecolor()

Get the face color of the Figure rectangle

get_figheight()

Return the figheight as a float

get_figwidth()

Return the figwidth as a float

get_frameon()

get the boolean indicating frameon

get_size_inches()
get_tightbbox(renderer)

Return a (tight) bounding box of the figure in inches.

It only accounts axes title, axis labels, and axis ticklabels. Needs improvement.

get_window_extent(*args, **kwargs)

get the figure bounding box in display space; kwargs are void

ginput(n=1, timeout=30, show_clicks=True, mouse_add=1, mouse_pop=3, mouse_stop=2)

call signature:

ginput(self, n=1, timeout=30, show_clicks=True,
       mouse_add=1, mouse_pop=3, mouse_stop=2)

Blocking call to interact with the figure.

This will wait for n clicks from the user and return a list of the coordinates of each click.

If timeout is zero or negative, does not timeout.

If n is zero or negative, accumulate clicks until a middle click (or potentially both mouse buttons at once) terminates the input.

Right clicking cancels last input.

The buttons used for the various actions (adding points, removing points, terminating the inputs) can be overriden via the arguments mouse_add, mouse_pop and mouse_stop, that give the associated mouse button: 1 for left, 2 for middle, 3 for right.

The keyboard can also be used to select points in case your mouse does not have one or more of the buttons. The delete and backspace keys act like right clicking (i.e., remove last point), the enter key terminates input and any other key (not already used by the window manager) selects a point.

hold(b=None)

Set the hold state. If hold is None (default), toggle the hold state. Else set the hold state to boolean value b.

Eg:

hold()      # toggle hold
hold(True)  # hold is on
hold(False) # hold is off
legend(handles, labels, *args, **kwargs)

Place a legend in the figure. Labels are a sequence of strings, handles is a sequence of Line2D or Patch instances, and loc can be a string or an integer specifying the legend location

USAGE:

legend( (line1, line2, line3),
        ('label1', 'label2', 'label3'),
        'upper right')

The loc location codes are:

'best' : 0,          (currently not supported for figure legends)
'upper right'  : 1,
'upper left'   : 2,
'lower left'   : 3,
'lower right'  : 4,
'right'        : 5,
'center left'  : 6,
'center right' : 7,
'lower center' : 8,
'upper center' : 9,
'center'       : 10,

loc can also be an (x,y) tuple in figure coords, which specifies the lower left of the legend box. figure coords are (0,0) is the left, bottom of the figure and 1,1 is the right, top.

Keyword arguments:

prop: [ None | FontProperties | dict ]
A matplotlib.font_manager.FontProperties instance. If prop is a dictionary, a new instance will be created with prop. If None, use rc settings.
numpoints: integer
The number of points in the legend line, default is 4
scatterpoints: integer
The number of points in the legend line, default is 4
scatteroffsets: list of floats
a list of yoffsets for scatter symbols in legend
markerscale: [ None | scalar ]
The relative size of legend markers vs. original. If None, use rc settings.
fancybox: [ None | False | True ]
if True, draw a frame with a round fancybox. If None, use rc
shadow: [ None | False | True ]
If True, draw a shadow behind legend. If None, use rc settings.
ncol : integer
number of columns. default is 1
mode : [ “expand” | None ]
if mode is “expand”, the legend will be horizontally expanded to fill the axes area (or bbox_to_anchor)
title : string
the legend title

Padding and spacing between various elements use following keywords parameters. The dimensions of these values are given as a fraction of the fontsize. Values from rcParams will be used if None.

Keyword Description
borderpad the fractional whitespace inside the legend border
labelspacing the vertical space between the legend entries
handlelength the length of the legend handles
handletextpad the pad between the legend handle and text
borderaxespad the pad between the axes and legend border
columnspacing the spacing between columns

Example:

[source code, hires.png, pdf]

../_images/figlegend_demo.png
savefig(*args, **kwargs)

call signature:

savefig(fname, dpi=None, facecolor='w', edgecolor='w',
        orientation='portrait', papertype=None, format=None,
        transparent=False, bbox_inches=None, pad_inches=0.1):

Save the current figure.

The output formats available depend on the backend being used.

Arguments:

fname:

A string containing a path to a filename, or a Python file-like object, or possibly some backend-dependent object such as PdfPages.

If format is None and fname is a string, the output format is deduced from the extension of the filename. If the filename has no extension, the value of the rc parameter savefig.extension is used. If that value is ‘auto’, the backend determines the extension.

If fname is not a string, remember to specify format to ensure that the correct backend is used.

Keyword arguments:

dpi: [ None | scalar > 0 ]
The resolution in dots per inch. If None it will default to the value savefig.dpi in the matplotlibrc file.
facecolor, edgecolor:
the colors of the figure rectangle
orientation: [ ‘landscape’ | ‘portrait’ ]
not supported on all backends; currently only on postscript output
papertype:
One of ‘letter’, ‘legal’, ‘executive’, ‘ledger’, ‘a0’ through ‘a10’, ‘b0’ through ‘b10’. Only supported for postscript output.
format:
One of the file extensions supported by the active backend. Most backends support png, pdf, ps, eps and svg.
transparent:
If True, the axes patches will all be transparent; the figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs. This is useful, for example, for displaying a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function.
bbox_inches:
Bbox in inches. Only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure.
pad_inches:
Amount of padding around the figure when bbox_inches is ‘tight’.
bbox_extra_artists:
A list of extra artists that will be considered when the tight bbox is calculated.
sca(a)

Set the current axes to be a and return a

set_canvas(canvas)

Set the canvas the contains the figure

ACCEPTS: a FigureCanvas instance

set_dpi(val)

Set the dots-per-inch of the figure

ACCEPTS: float

set_edgecolor(color)

Set the edge color of the Figure rectangle

ACCEPTS: any matplotlib color - see help(colors)

set_facecolor(color)

Set the face color of the Figure rectangle

ACCEPTS: any matplotlib color - see help(colors)

set_figheight(val)

Set the height of the figure in inches

ACCEPTS: float

set_figwidth(val)

Set the width of the figure in inches

ACCEPTS: float

set_frameon(b)

Set whether the figure frame (background) is displayed or invisible

ACCEPTS: boolean

set_size_inches(*args, **kwargs)

set_size_inches(w,h, forward=False)

Set the figure size in inches

Usage:

fig.set_size_inches(w,h)  # OR
fig.set_size_inches((w,h) )

optional kwarg forward=True will cause the canvas size to be automatically updated; eg you can resize the figure window from the shell

ACCEPTS: a w,h tuple with w,h in inches

subplots_adjust(*args, **kwargs)
fig.subplots_adjust(left=None, bottom=None, right=None, top=None,
wspace=None, hspace=None)

Update the SubplotParams with kwargs (defaulting to rc where None) and update the subplot locations

suptitle(t, **kwargs)

Add a centered title to the figure.

kwargs are matplotlib.text.Text properties. Using figure coordinates, the defaults are:

  • x = 0.5

    the x location of text in figure coords

  • y = 0.98

    the y location of the text in figure coords

  • horizontalalignment = ‘center’

    the horizontal alignment of the text

  • verticalalignment = ‘top’

    the vertical alignment of the text

A matplotlib.text.Text instance is returned.

Example:

fig.suptitle('this is the figure title', fontsize=12)
text(x, y, s, *args, **kwargs)

Call signature:

figtext(x, y, s, fontdict=None, **kwargs)

Add text to figure at location x, y (relative 0-1 coords). See text() for the meaning of the other arguments.

kwargs control the Text properties:

Property Description
agg_filter unknown
alpha float (0.0 transparent through 1.0 opaque)
animated [True | False]
axes an Axes instance
backgroundcolor any matplotlib color
bbox rectangle prop dict
clip_box a matplotlib.transforms.Bbox instance
clip_on [True | False]
clip_path [ (Path, Transform) | Patch | None ]
color any matplotlib color
contains a callable function
family or fontfamily or fontname or name [ FONTNAME | ‘serif’ | ‘sans-serif’ | ‘cursive’ | ‘fantasy’ | ‘monospace’ ]
figure a matplotlib.figure.Figure instance
fontproperties or font_properties a matplotlib.font_manager.FontProperties instance
gid an id string
horizontalalignment or ha [ ‘center’ | ‘right’ | ‘left’ ]
label any string
linespacing float (multiple of font size)
lod [True | False]
multialignment [‘left’ | ‘right’ | ‘center’ ]
path_effects unknown
picker [None|float|boolean|callable]
position (x,y)
rasterized [True | False | None]
rotation [ angle in degrees | ‘vertical’ | ‘horizontal’ ]
rotation_mode unknown
size or fontsize [ size in points | ‘xx-small’ | ‘x-small’ | ‘small’ | ‘medium’ | ‘large’ | ‘x-large’ | ‘xx-large’ ]
snap unknown
stretch or fontstretch [ a numeric value in range 0-1000 | ‘ultra-condensed’ | ‘extra-condensed’ | ‘condensed’ | ‘semi-condensed’ | ‘normal’ | ‘semi-expanded’ | ‘expanded’ | ‘extra-expanded’ | ‘ultra-expanded’ ]
style or fontstyle [ ‘normal’ | ‘italic’ | ‘oblique’]
text string or anything printable with ‘%s’ conversion.
transform Transform instance
url a url string
variant or fontvariant [ ‘normal’ | ‘small-caps’ ]
verticalalignment or va or ma [ ‘center’ | ‘top’ | ‘bottom’ | ‘baseline’ ]
visible [True | False]
weight or fontweight [ a numeric value in range 0-1000 | ‘ultralight’ | ‘light’ | ‘normal’ | ‘regular’ | ‘book’ | ‘medium’ | ‘roman’ | ‘semibold’ | ‘demibold’ | ‘demi’ | ‘bold’ | ‘heavy’ | ‘extra bold’ | ‘black’ ]
x float
y float
zorder any number
waitforbuttonpress(timeout=-1)

call signature:

waitforbuttonpress(self, timeout=-1)

Blocking call to interact with the figure.

This will return True is a key was pressed, False if a mouse button was pressed and None if timeout was reached without either being pressed.

If timeout is negative, does not timeout.

class matplotlib.figure.SubplotParams(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)

A class to hold the parameters for a subplot

All dimensions are fraction of the figure width or height. All values default to their rc params

The following attributes are available

left = 0.125
the left side of the subplots of the figure
right = 0.9
the right side of the subplots of the figure
bottom = 0.1
the bottom of the subplots of the figure
top = 0.9
the top of the subplots of the figure
wspace = 0.2
the amount of width reserved for blank space between subplots
hspace = 0.2
the amount of height reserved for white space between subplots
validate
make sure the params are in a legal state (left*<*right, etc)
update(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)

Update the current values. If any kwarg is None, default to the current value, if set, otherwise to rc

matplotlib.figure.figaspect(arg)

Create a figure with specified aspect ratio. If arg is a number, use that aspect ratio. If arg is an array, figaspect will determine the width and height for a figure that would fit array preserving aspect ratio. The figure width, height in inches are returned. Be sure to create an axes with equal with and height, eg

Example usage:

# make a figure twice as tall as it is wide
w, h = figaspect(2.)
fig = Figure(figsize=(w,h))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax.imshow(A, **kwargs)


# make a figure with the proper aspect for an array
A = rand(5,3)
w, h = figaspect(A)
fig = Figure(figsize=(w,h))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax.imshow(A, **kwargs)

Thanks to Fernando Perez for this function