no guihandless with labels found to put in legend怎么办

simonhenin/columnlegend
version 3.0.0.0 (53.4 KB) by
458 downloads
Creates a legend with a specified number of columns
437 Downloads
Editor's Note: This file was selected as MATLAB Central
Updated 9/8/16: Added new legend positions (e.g. northeastoutside) and better positioning.
numlines = 5;
r = rand(10,numlines);
columnlegend(2, cellstr(num2str([1:numlines]')), 'location', 'northeastoutside');
PRINTING: If you want to print the figure, you'll have to use a command line printer (e.g. export_fig) as the File-&Print option embedded in the figure resets the figure properties including the legend
Comments and Ratings (147)
0 downloads
27 Jul 2018
0 downloads
27 Jul 2018
458 downloads
19 Jul 2018
0 downloads
19 Jul 2018
0 downloads
19 Jul 2018
0 downloads
16 Jul 2018
0 downloads
13 Jul 2018
458 downloads
13 Jul 2018
0 downloads
13 Jul 2018
0 downloads
4 Jul 2018
Hi, is there a way to adjust font size in columnlegend?
0 downloads
28 Jun 2018
I solved it already Simon, I just set the 'padding' to zero :)
Function works perfect, many thanks for sharing it
458 downloads
27 Jun 2018
0 downloads
27 Jun 2018
0 downloads
26 Jun 2018
i m using Matlab2017b
maxfig(V_rT,1)
set(0,'CurrentFigure',V_rT);
columnlegend(6,legend_str,'Location','Southoutside');
I got an error saying:
Error using matlab.graphics.axis.Axes/set
Error setting property 'Position' of class 'Axes':
Width and height must be greater than or equal to 0
Error in columnlegend (line 205)
set(gca, 'position', [fig_pos]-[0 -pos(4) 0 pos(4)]);
47 downloads
4 Jun 2018
0 downloads
18 May 2018
awesome! thanks
0 downloads
11 May 2018
0 downloads
3 May 2018
0 downloads
3 May 2018
0 downloads
25 Apr 2018
Thank you simon
0 downloads
23 Apr 2018
0 downloads
21 Apr 2018
0 downloads
20 Apr 2018
0 downloads
19 Apr 2018
0 downloads
18 Apr 2018
Dear Simon,
Is there any way to set input argument as specific axes. I want to give legend to specific axes like &legend(target,__)&. I am using &plot(AX,...)& plots into the axes with handle AX. Thank you.
0 downloads
18 Apr 2018
@ Dear Simon,
Thank you so much. It's working now. I am new in Matlab. I have one more question. I have 10 plots in a figure. When I was trying to use column legend in my code for example
columnlegend(2, 'a', 'b', 'c', 'd', 'e', 'f', ‘g’,’h’,’i’,’j’, 'location', 'northeastoutside')
It shows just first legend
in the graph.
Can you please help me to solve this problem?
0 downloads
17 Apr 2018
0 downloads
17 Apr 2018
0 downloads
11 Apr 2018
0 downloads
10 Apr 2018
Dear Simon,
Well, I figured out the mistake, so need to worry here. I forgot {'object1,object2} - the clams around the objects. Stupidy when working in MATLAB at 22:00 :D
It was awesome, thank you!
Best Regards,
0 downloads
3 Apr 2018
0 downloads
3 Apr 2018
0 downloads
29 Mar 2018
0 downloads
27 Mar 2018
458 downloads
26 Mar 2018
0 downloads
25 Mar 2018
458 downloads
24 Mar 2018
0 downloads
23 Mar 2018
Hi! This is awesome! One quick question: does this have the functionality to skip legend entries? If I have, for example, 8 lines plotted, but I only want to have legend entries/symbols for the last four lines?
0 downloads
13 Mar 2018
0 downloads
3 Mar 2018
For those who are interested in getting Latex interpreter for the Legend. Change the line
[legend_h,object_h,plot_h,text_strings] = legend(str);
[legend_h,object_h,plot_h,text_strings] = legend(str,'interpreter','latex','FontSize',12);
and put $$ at appropriate locations when making the call, e.g.,
columnlegend(2, {'$f(z)$'}, 'location', 'northeast');
0 downloads
20 Feb 2018
0 downloads
13 Feb 2018
Thank you for sharing this code.
I think I found a tiny bug though.
In line 41, the steps in the for loop shouldn't be 1 instead of 2? The 2 jumps are included in the cases when needed.
The 'boxon' and 'boxoff' doesn't require the step to be 2, for example.
Also, any tips on how to include a latex interpreter for the legends?
0 downloads
26 Jan 2018
Thank you for sharing the code
0 downloads
23 Jan 2018
0 downloads
23 Jan 2018
Thanks for the nice code.
I want to put the legend in the southwest, can you list the objects of legend like this:
0 downloads
7 Dec 2017
There is error in line 138,' There is no ydata property on the Group class', there is scatter and plot in my figure
0 downloads
1 Dec 2017
0 downloads
30 Nov 2017
0 downloads
30 Nov 2017
0 downloads
30 Nov 2017
0 downloads
31 Oct 2017
0 downloads
17 Oct 2017
Perfect. Just what I needed thanks.
0 downloads
5 Oct 2017
@Simon Henin
It's a very usefull code,thank you very much.
I found it doesn't work when i choose 'hist' of bar, why? follow is a example in Matlab 2017a:
y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];
h=bar(y,'hist')
columnlegend(3,cellstr(num2str([1:3]')),'location','eastoutside');
0 downloads
14 Sep 2017
0 downloads
11 Sep 2017
0 downloads
28 Aug 2017
0 downloads
14 Aug 2017
0 downloads
19 Jul 2017
0 downloads
19 Jul 2017
0 downloads
14 Jul 2017
0 downloads
3 Jul 2017
0 downloads
21 Jun 2017
458 downloads
11 Jun 2017
0 downloads
9 Jun 2017
458 downloads
8 Jun 2017
0 downloads
6 Jun 2017
458 downloads
5 Jun 2017
0 downloads
3 Jun 2017
0 downloads
5 Apr 2017
0 downloads
24 Mar 2017
This is a great function but unfortunately it does not support patches:
&& h=patch('FaceColor',[1 0 0],'EdgeColor','black');
&& columnlegend(h,1,'TEST', 'location', 'northeast','boxoff');
Is this something that could be added in the future?
Thanks a lot!
458 downloads
15 Mar 2017
11 downloads
6 Mar 2017
This I use it all the time and it makes plots look more professional.
But I'm getting errors with R2016b if I resize axes containing a columnlegend:
Struct contents reference from a non-struct array object.
Error in matlab.graphics.illustration.Legend/doMethod&doUpdateCompatible
Error in matlab.graphics.illustration.Legend/doMethod
Error in matlab.graphics.illustration.Legend/doUpdate
Anyone have a workaround? I've submitted a bug report to MathWorks but they say it's &third-party software& and therefore not their problem.
0 downloads
24 Feb 2017
0 downloads
23 Feb 2017
0 downloads
21 Feb 2017
You can change the font size and type by using this easy code:
leg_str={'\fontname{Times New Roman}\fontsize{13} data 1','\fontname{Times New Roman}\fontsize{13} data2')
h = columnlegend(2,leg_str);
0 downloads
20 Feb 2017
Many thanks for your quick reply. It solves my issue.
458 downloads
17 Feb 2017
0 downloads
17 Feb 2017
0 downloads
20 Dec 2016
0 downloads
19 Nov 2016
458 downloads
18 Nov 2016
0 downloads
18 Nov 2016
Congrats on this awesome function, however the Interpreter cannot be switched off which leads to annoying legend display when using underscores.
0 downloads
9 Nov 2016
458 downloads
1 Nov 2016
0 downloads
1 Nov 2016
0 downloads
28 Oct 2016
458 downloads
20 Oct 2016
0 downloads
17 Oct 2016
0 downloads
15 Oct 2016
458 downloads
8 Sep 2016
0 downloads
8 Sep 2016
does not work for outside legends...
0 downloads
5 Aug 2016
0 downloads
23 Jul 2016
0 downloads
12 Jul 2016
0 downloads
12 Jul 2016
0 downloads
12 Jul 2016
458 downloads
6 Jul 2016
0 downloads
6 Jul 2016
Is there any way of setting the FontName? It doesn't seem to work for me:
leg_str={'Text A','Text B','Text C'};
h = columnlegend(3,leg_str);
set(h,'position',[0.15,0.85,0.75,0.1],'FontName','Times New Roman')
0 downloads
30 May 2016
0 downloads
17 Apr 2016
0 downloads
8 Apr 2016
0 downloads
20 Mar 2016
0 downloads
14 Feb 2016
458 downloads
25 Jan 2016
0 downloads
25 Jan 2016
458 downloads
31 Oct 2015
0 downloads
30 Oct 2015
0 downloads
1 Sep 2015
0 downloads
31 Jul 2015
0 downloads
25 Jun 2015
Good job for creating the layout.
Some modifications can be made to handle scatter plots, which consist of only one element in legend (linenum = linenum+1;)
I haven't tried with other types of plots
0 downloads
26 May 2015
very good!
51 downloads
20 May 2015
Very useful and simple to use.
0 downloads
11 May 2015
This works out great! The only thing I would like to change is, that the legend can also be located outside the diagram (e.g. 'southwestoutside')
The only possible values at the moment are: 'NorthWest', 'NorthEast', 'SouthEast', 'SouthWest'
Could somebody help me, at which point I would have to adapt the code?
0 downloads
1 Mar 2015
0 downloads
5 Feb 2014
0 downloads
10 Jan 2014
This is a great tool for relatively simple needs, but I found immediately that I can't do much additional legend customization.
Just doing
set(lh,'fontsize',8) caused my legend to revert to a single column.
Could you include more input options or perhaps make the legend in a way that changing other properties won't affect the layout?
0 downloads
9 Jan 2014
That's great! Thank you very much.
I wish it also support 'Best' location like the legend of Matlab.
0 downloads
30 Dec 2013
It works very fine with me, I highly recommend to use export_fig to print the plots. I think that it will be a nice improvement if we can pick a 'North' location for example, 'cause if you need to put in the middle of the figure you must move the legend with get 'Position' and set 'Position'. Best Regards Simon.
0 downloads
14 Nov 2013
0 downloads
31 Oct 2013
458 downloads
17 Oct 2013
0 downloads
16 Oct 2013
0 downloads
16 Oct 2013
0 downloads
16 Oct 2013
0 downloads
13 Oct 2013
0 downloads
13 Oct 2013
458 downloads
5 Aug 2013
0 downloads
5 Aug 2013
Hey. Very nice function. Just what i needed.
Is there any way to make it non-transparent? My graphs are making the text somewhat illegible.
0 downloads
7 Jul 2013
0 downloads
4 Jul 2013
Hi, very nice part of code! But the columns of legend are put together ones the .eps figure is printed. Do you have any idea how to fix it?
0 downloads
30 Apr 2013
158 downloads
10 Apr 2013
very useful
0 downloads
27 Sep 2012
0 downloads
13 Jun 2012
I found a bug of this program. For example, when you try to change 1_by_2 legends to 2_by_1, this program will not work. Because the numpercolumn is 1, and the col is always -1.
Replace the code
if mod(i,numpercolumn)==1,
col = col+1;
if numpercolumn&1,
if mod(i,numpercolumn)==1,
col = col+1;
to kill this bug.
0 downloads
13 Jun 2012
71 downloads
20 May 2012
0 downloads
16 Mar 2012
458 downloads
16 Mar 2012
0 downloads
16 Mar 2012
0 downloads
6 Mar 2012
Update: The problems probably has nothing to do with subplots (tried it in a simple example). Error message:
??? Index exceeds matrix dimensions.
Error in ==& columnlegend at 77
set(object_h(linenum), 'ydata', [(height-(position-1)*sheight)
(height-(position-1)*sheight)]);
0 downloads
6 Mar 2012
458 downloads
6 Dec 2011
0 downloads
6 Dec 2011
452 downloads
5 Sep 2011
458 downloads
8 Feb 2011
0 downloads
8 Feb 2011
0 downloads
6 Jul 2010
MATLAB Release Compatibility
Created with
Compatible with
any release
Platform Compatibility
Windows macOS Linux
Acknowledgements
MATLAB Online Live Editor Challenge
Win cash prizes and have your live script featured on our website
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
(Fran?ais)
(Italiano)
Switzerland
Asia Pacificpyplot & Matplotlib 2.0.2 documentation
Navigation
Provides a MATLAB-like plotting framework.
pylab combines pyplot with numpy into a single namespace.
This is convenient for interactive work, but for programming it
is recommended that the namespaces be kept separate, e.g.:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)
matplotlib.pyplot.acorr(x, hold=None, data=None, **kwargs)
Plot the autocorrelation of x.
Parameters:x : sequence of scalar
hold : boolean, optional, deprecated, default: True
detrend : callable, optional, default: mlab.detrend_none
x is detrended by the detrend callable. Default is no
normalization.
normed : boolean, optional, default: True
if True, input vectors are normalised to unit length.
usevlines : boolean, optional, default: True
if True, Axes.vlines is used to plot the vertical lines from the
origin to the acorr. Otherwise, Axes.plot is used.
maxlags : integer, optional, default: 10
number of lags to show. If None, will return all 2 * len(x) - 1
Returns:(lags, c, line, b) : where:
lags are a length 2`maxlags+1 lag vector.
c is the 2`maxlags+1 auto correlation vectorI
instance returned by
b is the x-axis.
Other Parameters:
 linestyle :
prop, optional, default: None
Only used if usevlines is False.
marker : string, optional, default: ‘o’
The cross correlation is performed with numpy.correlate() with
is top graph, and
is bottom graph.
In addition to the above described arguments, this function can take a
data keyword argument. If such a data argument is given, the
following arguments are replaced by data[&arg&]:
All arguments with the following names: ‘x’.
matplotlib.pyplot.angle_spectrum(x, Fs=None, Fc=None, window=None, pad_to=None, sides=None, hold=None, data=None, **kwargs)
Plot the angle spectrum.
Call signature:
angle_spectrum(x, Fs=2, Fc=0,
window=mlab.window_hanning,
pad_to=None, sides='default', **kwargs)
Compute the angle spectrum (wrapped phase spectrum) of x.
Data is padded to a length of pad_to and the windowing function
window is applied to the signal.
Parameters:x : 1-D array or sequence
Array or sequence containing the data
Fs : scalar
The sampling frequency (samples per time unit). It is used
to calculate the Fourier frequencies, freqs, in cycles per time
unit. The default value is 2.
window : callable or ndarray
A function or a vector of length NFFT. To create window
vectors see window_hanning(), window_none(),
numpy.blackman(), numpy.hamming(),
numpy.bartlett(), scipy.signal(),
scipy.signal.get_window(), etc. The default is
window_hanning(). If a function is passed as the
argument, it must take a data segment as an argument and
return the windowed version of the segment.
sides : [ ‘default’ | ‘onesided’ | ‘twosided’ ]
Specifies which sides of the spectrum to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. ‘onesided’ forces the return of a one-sided
spectrum, while ‘twosided’ forces two-sided.
pad_to : integer
The number of points to which the data segment is padded when
performing the FFT. While not increasing the actual resolution of
the spectrum (the minimum distance between resolvable peaks),
this can give more points in the plot, allowing for more
detail. This corresponds to the n parameter in the call to fft().
The default is None, which sets pad_to equal to the length of the
input signal (i.e. no padding).
Fc : integer
The center frequency of x (defaults to 0), which offsets
the x extents of the plot to reflect the frequency range used
when a signal is acquired and then filtered and downsampled to
**kwargs :
Keyword arguments control the
properties:
float (0.0 transparent through 1.0 opaque)
[True | False]
[True | False]
[True | False]
any matplotlib color
a callable function
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
sequence of on/off ink in points
[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’]
[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’]
an id string
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float value in points
any matplotlib color
float value in points
any matplotlib color
any matplotlib color
[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
float distance in points or callable pick function fn(artist, event)
float distance in points
[True | False | None]
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
a url string
[True | False]
any number
Returns:spectrum : 1-D array
The values for the angle spectrum in radians (real valued)
freqs : 1-D array
The frequencies corresponding to the elements in spectrum
The line created by this function
plots the magnitudes of the corresponding frequencies.
plots the unwrapped version of this function.
can plot the angle spectrum of segments within the signal in a colormap.
In addition to the above described arguments, this function can take a data keyword argument. If such a data argument is given, the following arguments are replaced by data[&arg&]: * All arguments with the following names: ‘x’.
matplotlib.pyplot.annotate(*args, **kwargs)
Annotate the point xy with text s.
Additional kwargs are passed to .
Parameters:s : str
The text of the annotation
xy : iterable
Length 2 sequence specifying the (x,y) point to annotate
xytext : iterable, optional
Length 2 sequence specifying the (x,y) to place the text
at. If None, defaults to xy.
xycoords : str, Artist, Transform, callable or tuple, optional
The coordinate system that xy is given in.
For a str the allowed values are:
‘figure points’
points from the lower left of the figure
‘figure pixels’
pixels from the lower left of the figure
‘figure fraction’
fraction of figure from lower left
‘axes points’
points from lower left corner of axes
‘axes pixels’
pixels from lower left corner of axes
‘axes fraction’
fraction of axes from lower left
‘data’
use the coordinate system of the object being
annotated (default)
‘polar’
(theta,r) if not native ‘data’ coordinates
object is passed in the units are
fraction if it’s bounding box.
object is passed
in use that to transform xy to screen coordinates
If a callable it must take a
object as input
and return a
If a tuple must be length 2 tuple of str, Artist,
Transform or callable objects. The first transform is
used for the x coordinate and the second for y.
for more details.
Defaults to 'data'
textcoords : str, Artist, Transform, callable or tuple, optional
The coordinate system that xytext is given, which
may be different than the coordinate system used for
All xycoords values are valid as well as the following
‘offset points’
offset (in points) from the xy value
‘offset pixels’
offset (in pixels) from the xy value
defaults to the input of xycoords
arrowprops : dict, optional
If not None, properties used to draw a
arrow between xy and
If arrowprops does not contain the key 'arrowstyle' the
allowed keys are:
the width of the arrow in points
the width of the base of the arrow head in points
headlength
the length of the arrow head in points
fraction of total length to ‘shrink’ from both ends
any key to
If the arrowprops contains the key 'arrowstyle' the
above keys are forbidden. The allowed values of
'arrowstyle' are:
head_length=0.4,head_width=0.2
widthB=1.0,lengthB=0.2,angleB=None
widthA=1.0,widthB=1.0
head_length=0.4,head_width=0.2
head_length=0.4,head_width=0.2
head_length=0.4,head_width=0.2
head_length=0.4,head_width=0.2
head_length=0.4,head_width=0.2
head_length=0.4,head_width=0.4,tail_width=0.4
head_length=0.5,head_width=0.5,tail_width=0.2
tail_width=0.3,shrink_factor=0.5
Valid keys for
arrowstyle
the arrow style
connectionstyle
the connection style
default is (0.5, 0.5)
default is bounding box of the text
default is None
default is 2 points
default is 2 points
mutation_scale
default is text size (in points)
mutation_aspect
default is 1.
any key for
Defaults to None
annotation_clip : bool, optional
Controls the visibility of the annotation when it goes
outside the axes area.
If True, the annotation will only be drawn when the
xy is inside the axes. If False, the annotation will
always be drawn regardless of its position.
The default is None, which behave as True only if
xycoords is “data”.
Returns:Annotation
matplotlib.pyplot.arrow(x, y, dx, dy, hold=None, **kwargs)
Add an arrow to the axes.
Draws arrow on specified axis from (x, y) to (x + dx,
y + dy). Uses FancyArrow patch to construct the arrow.
Parameters:x : float
X-coordinate of the arrow base
Y-coordinate of the arrow base
dx : float
Length of arrow along x-coordinate
dy : float
Length of arrow along y-coordinate
Returns:a : FancyArrow
patches.FancyArrow object
Other Parameters:
 Optional kwargs (inherited from FancyArrow patch) control the arrow
construction and properties:
Constructor arguments
width: float (default: 0.001)
width of full arrow tail
length_includes_head: [True | False] (default: False)
True if head is to be counted in calculating the length.
head_width: float or None (default: 3*width)
total width of the full arrow head
head_length: float or None (default: 1.5 * head_width)
length of arrow head
shape: [‘full’, ‘left’, ‘right’] (default: ‘full’)
draw the left-half, right-half, or full arrow
overhang: float (default: 0)
fraction that the arrow is swept back (0 overhang means
triangular shape). Can be negative or greater than one.
head_starts_at_zero: [True | False] (default: False)
if True, the head starts being drawn at coordinate 0
instead of ending at coordinate 0.
Other valid kwargs (inherited from :class:`Patch`) are:
float or None
[True | False]
[True | False] or None for default
[‘butt’ | ‘round’ | ‘projecting’]
[True | False]
matplotlib color spec
a callable function
mpl color spec, None, ‘none’, or ‘auto’
mpl color spec, or None for default, or ‘none’ for no color
[True | False]
an id string
[‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]
[‘miter’ | ‘round’ | ‘bevel’]
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float or None for default
[None|float|boolean|callable]
[True | False | None]
a url string
[True | False]
any number
The resulting arrow is affected by the axes aspect ratio and limits.
This may produce an arrow whose head is not square with its stem. To
create an arrow whose head is square with its stem, use
for example:
ax.annotate(&&, xy=(0.5, 0.5), xytext=(0, 0),
arrowprops=dict(arrowstyle=&-&&))
matplotlib.pyplot.autoscale(enable=True, axis='both', tight=None)
Autoscale the axis view to the data (toggle).
Convenience method for simple axis view autoscaling.
It turns autoscaling on or off, and then,
if autoscaling for either axis is on, it performs
the autoscaling on the specified axis or axes.
enable: [True | False | None]
True (default) turns autoscaling on, False turns it off.
None leaves the autoscaling state unchanged.
axis: [‘x’ | ‘y’ | ‘both’]
whic default is ‘both’
tight: [True | False | None]
If True, set view l
if False, let the locator and margins ex
if None, use tight scaling if the only artist is an image,
otherwise treat tight as False.
The tight setting is retained for future autoscaling
until it is explicitly changed.
Returns None.
matplotlib.pyplot.autumn()
set the default colormap to autumn and apply to current image if any.
See help(colormaps) for more information
matplotlib.pyplot.axes(*args, **kwargs)
Add an axes to the figure.
The axes is added at position rect specified by:
axes() by itself creates a default full subplot(111) window axis.
axes(rect, facecolor='w') where rect = [left, bottom, width,
height] in normalized (0, 1) units. facecolor is the background
color for the axis, default white.
axes(h) where h is an axes instance makes h the current
instance is returned.
the axes background color
[True|False]
display the frame?
current axes shares xaxis attribute
with otherax
current axes shares yaxis attribute
with otherax
[True|False]
use a polar axes?
[str | num]
[‘equal’, ‘auto’] or a number. If a number
the ratio of x-unit/y-unit in screen-space.
examples/pylab_examples/axes_demo.py places custom axes.
examples/pylab_examples/shared_axis_demo.py uses
sharex and sharey.
matplotlib.pyplot.axhline(y=0, xmin=0, xmax=1, hold=None, **kwargs)
Add a horizontal line across the axis.
Parameters:y : scalar, optional, default: 0
y position in data coordinates of the horizontal line.
xmin : scalar, optional, default: 0
Should be between 0 and 1, 0 being the far left of the plot, 1 the
far right of the plot.
xmax : scalar, optional, default: 1
Should be between 0 and 1, 0 being the far left of the plot, 1 the
far right of the plot.
for example plot and source code
kwargs are passed to
and can be used
to control the line properties.
draw a thick red hline at ‘y’ = 0 that spans the xrange:
&&& axhline(linewidth=4, color='r')
draw a default hline at ‘y’ = 1 that spans the xrange:
&&& axhline(y=1)
draw a default hline at ‘y’ = .5 that spans the middle half of
the xrange:
&&& axhline(y=.5, xmin=0.25, xmax=0.75)
Valid kwargs are
properties,
with the exception of ‘transform’:
float (0.0 transparent through 1.0 opaque)
[True | False]
[True | False]
[True | False]
any matplotlib color
a callable function
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
sequence of on/off ink in points
[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’]
[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’]
an id string
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float value in points
any matplotlib color
float value in points
any matplotlib color
any matplotlib color
[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
float distance in points or callable pick function fn(artist, event)
float distance in points
[True | False | None]
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
a url string
[True | False]
any number
matplotlib.pyplot.axhspan(ymin, ymax, xmin=0, xmax=1, hold=None, **kwargs)
Add a horizontal span (rectangle) across the axis.
Draw a horizontal span (rectangle) from ymin to ymax.
With the default values of xmin = 0 and xmax = 1, this
always spans the xrange, regardless of the xlim settings, even
if you change them, e.g., with the set_xlim() command.
That is, the horizontal extent is in axes coords: 0=left,
0.5=middle, 1.0=right but the y location is in data
coordinates.
Parameters:ymin : float
Lower limit of the horizontal span in data units.
ymax : float
Upper limit of the horizontal span in data units.
xmin : float, optional, default: 0
Lower limit of the vertical span in axes (relative
0-1) units.
xmax : float, optional, default: 1
Upper limit of the vertical span in axes (relative
0-1) units.
Returns:Polygon :
Other Parameters:
 kwargs :
properties.
float or None
[True | False]
[True | False] or None for default
[‘butt’ | ‘round’ | ‘projecting’]
[True | False]
matplotlib color spec
a callable function
mpl color spec, None, ‘none’, or ‘auto’
mpl color spec, or None for default, or ‘none’ for no color
[True | False]
an id string
[‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]
[‘miter’ | ‘round’ | ‘bevel’]
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float or None for default
[None|float|boolean|callable]
[True | False | None]
a url string
[True | False]
any number
Add a vertical span (rectangle) across the axes.
matplotlib.pyplot.axis(*v, **kwargs)
Convenience method to get or set axis properties.
Calling with no arguments:
&&& axis()
returns the current axes limits [xmin, xmax, ymin, ymax].:
&&& axis(v)
sets the min and max of the x and y axes, with
v = [xmin, xmax, ymin, ymax].:
&&& axis('off')
turns off the axis lines and labels.:
&&& axis('equal')
changes limits of x or y axis so that equal increments of x
a circle is circular.:
&&& axis('scaled')
achieves the same result by changing the dimensions of the plot box instead
of the axis data limits.:
&&& axis('tight')
changes x and y axis limits such that all data is shown. If
all data is already shown, it will move it to the center of the
figure without modifying (xmax - xmin) or (ymax -
ymin). Note this is slightly different than in MATLAB.:
&&& axis('image')
is ‘scaled’ with the axis limits equal to the data limits.:
&&& axis('auto')
&&& axis('normal')
are deprecated. They rest axis limits are automatically
scaled to make the data fit comfortably within the plot box.
if len(*v)==0, you can pass in xmin, xmax, ymin, ymax
as kwargs selectively to alter just those limits without changing
the others.
&&& axis('square')
changes the limit ranges (xmax-xmin) and (ymax-ymin) of
the x and y axes to be the same, and have the same scaling,
resulting in a square plot.
The xmin, xmax, ymin, ymax tuple is returned
For setting the x- and y-limits individually.
matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, hold=None, **kwargs)
Add a vertical line across the axes.
Parameters:x : scalar, optional, default: 0
x position in data coordinates of the vertical line.
ymin : scalar, optional, default: 0
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
top of the plot.
ymax : scalar, optional, default: 1
Should be between 0 and 1, 0 being the bottom of the plot, 1 the
top of the plot.
for example plot and source code
draw a thick red vline at x = 0 that spans the yrange:
&&& axvline(linewidth=4, color='r')
draw a default vline at x = 1 that spans the yrange:
&&& axvline(x=1)
draw a default vline at x = .5 that spans the middle half of
the yrange:
&&& axvline(x=.5, ymin=0.25, ymax=0.75)
Valid kwargs are
properties,
with the exception of ‘transform’:
float (0.0 transparent through 1.0 opaque)
[True | False]
[True | False]
[True | False]
any matplotlib color
a callable function
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
sequence of on/off ink in points
[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’]
[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’]
an id string
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float value in points
any matplotlib color
float value in points
any matplotlib color
any matplotlib color
[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
float distance in points or callable pick function fn(artist, event)
float distance in points
[True | False | None]
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
a url string
[True | False]
any number
matplotlib.pyplot.axvspan(xmin, xmax, ymin=0, ymax=1, hold=None, **kwargs)
Add a vertical span (rectangle) across the axes.
Draw a vertical span (rectangle) from xmin to xmax. With
the default values of ymin = 0 and ymax = 1. This always
spans the yrange, regardless of the ylim settings, even if you
change them, e.g., with the set_ylim() command. That is,
the vertical extent is in axes coords: 0=bottom, 0.5=middle,
1.0=top but the y location is in data coordinates.
Parameters:xmin : scalar
Number indicating the first X-axis coordinate of the vertical
span rectangle in data units.
xmax : scalar
Number indicating the second X-axis coordinate of the vertical
span rectangle in data units.
ymin : scalar, optional
Number indicating the first Y-axis coordinate of the vertical
span rectangle in relative Y-axis units (0-1). Default to 0.
ymax : scalar, optional
Number indicating the second Y-axis coordinate of the vertical
span rectangle in relative Y-axis units (0-1). Default to 1.
Returns:rectangle : matplotlib.patches.Polygon
Vertical span (rectangle) from (xmin, ymin) to (xmax, ymax).
Other Parameters:
 **kwargs
Optional parameters are properties of the class
matplotlib.patches.Polygon.
Draw a vertical, green, translucent rectangle from x = 1.25 to
x = 1.55 that spans the yrange of the axes.
&&& axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs)
Make a bar plot.
Make a bar plot with rectangles bounded by:
left, left + width, bottom, bottom + height
(left, right, bottom and top edges)
Parameters:left : sequence of scalars
the x coordinates of the left sides of the bars
height : sequence of scalars
the heights of the bars
width : scalar or array-like, optional
the width(s) of the bars
default: 0.8
bottom : scalar or array-like, optional
the y coordinate(s) of the bars
default: None
color : scalar or array-like, optional
the colors of the bar faces
edgecolor : scalar or array-like, optional
the colors of the bar edges
linewidth : scalar or array-like, optional
width of bar edge(s). If None, use default
If 0, don’t draw edges.
default: None
tick_label : string or array-like, optional
the tick labels of the bars
default: None
xerr : scalar or array-like, optional
if not None, will be used to generate errorbar(s) on the bar chart
default: None
yerr : scalar or array-like, optional
if not None, will be used to generate errorbar(s) on the bar chart
default: None
ecolor : scalar or array-like, optional
specifies the color of errorbar(s)
default: None
capsize : scalar, optional
determines the length in points of the error bar caps
default: None, which will take the value from the
errorbar.capsize .
error_kw : dict, optional
dictionary of kwargs to be passed to errorbar method. ecolor and
capsize may be specified here rather than as independent kwargs.
align : {‘center’, ‘edge’}, optional
If ‘edge’, aligns bars by their left edges (for vertical bars) and
by their bottom edges (for horizontal bars). If ‘center’, interpret
the left argument as the coordinates of the centers of the bars.
To align on the align bars on the right edge pass a negative
orientation : {‘vertical’, ‘horizontal’}, optional
The orientation of the bars.
log : boolean, optional
If true, sets the axis to be log scale.
default: False
Returns:bars : matplotlib.container.BarContainer
Container with all of the bars + errorbars
Plot a horizontal bar plot.
The optional arguments color, edgecolor, linewidth,
xerr, and yerr can be either scalars or sequences of
length equal to the number of bars. This enables you to use
bar as the basis for stacked bar charts, or candlestick plots.
Detail: xerr and yerr are passed directly to
, so they can also have shape 2xN for
independent specification of lower and upper errors.
Other optional kwargs:
float or None
[True | False]
[True | False] or None for default
[‘butt’ | ‘round’ | ‘projecting’]
[True | False]
matplotlib color spec
a callable function
mpl color spec, None, ‘none’, or ‘auto’
mpl color spec, or None for default, or ‘none’ for no color
[True | False]
an id string
[‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]
[‘miter’ | ‘round’ | ‘bevel’]
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float or None for default
[None|float|boolean|callable]
[True | False | None]
a url string
[True | False]
any number
Example: A stacked bar chart.
In addition to the above described arguments, this function can take a
data keyword argument. If such a data argument is given, the
following arguments are replaced by data[&arg&]:
All arguments with the following names: ‘bottom’, ‘color’, ‘ecolor’, ‘edgecolor’, ‘height’, ‘left’, ‘linewidth’, ‘tick_label’, ‘width’, ‘xerr’, ‘yerr’.
matplotlib.pyplot.barbs(*args, **kw)
Plot a 2-D field of barbs.
Call signatures:
barb(U, V, **kw)
barb(U, V, C, **kw)
barb(X, Y, U, V, **kw)
barb(X, Y, U, V, C, **kw)
Arguments:
The x and y coordinates of the barb locations
(def see pivot kwarg)
Give the x and y components of the barb shaft
An optional array used to map colors to the barbs
All arguments may be 1-D or 2-D arrays or sequences. If X and Y
are absent, they will be generated as a uniform grid. If U and V
are 2-D arrays but X and Y are 1-D, and if len(X) and len(Y)
match the column and row dimensions of U, then X and Y will be
expanded with numpy.meshgrid().
U, V, C may be masked arrays, but masked X, Y are not
supported at present.
Keyword arguments:
Length o the other parts of the barb
are scaled against this.
Default is 9
pivot: [ ‘tip’ | ‘middle’ ]
The part of the arrow that
the arrow rotates
about this point, hence the name pivot. Default is ‘tip’
barbcolor: [ color | color sequence ]
Specifies the color all parts of the barb except any flags. This
parameter is analagous to the edgecolor parameter for polygons,
which can be used instead. However this parameter will override
facecolor.
flagcolor: [ color | color sequence ]
Specifies the color of any flags on the barb. This parameter is
analagous 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:
‘spacing’ - space between features (flags, full/half barbs)
‘height’ - height (distance from shaft to top) of a flag or
‘width’ - width of a flag, twice the width of a full barb
‘emptybarb’ - radius of the circle used for low magnitudes
fill_empty:
A flag on whether the empty barbs (circles) that are drawn should
be filled with the flag color. If they are not filled, they will
be drawn such that no color is applied to the center. Default is
A flag to indicate 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. Default is True
barb_increments:
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.
‘half’ - half barbs (Default is 5)
‘full’ - full barbs (Default is 10)
‘flag’ - flags (default is 50)
flip_barb:
Either a single boolean flag or an array of booleans. Single
boolean indicates whether the lines and flags should point
opposite to normal for all barbs. An array (which should be the
same size as the other data arrays) indicates whether to flip for
each individual barb. 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.) Default is
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.
linewidths and edgecolors can be used to customize the barb.
Additional
arguments:
float or None
[True | False]
or antialiaseds
Boolean or sequence of booleans
a length 2 sequence of floats
[True | False]
a colormap or registered colormap name
matplotlib color arg or sequence of rgba tuples
a callable function
or edgecolors
matplotlib color spec or sequence of specs
or facecolors
matplotlib color spec or sequence of specs
an id string
[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ]
string or anything printable with ‘%s’ conversion.
or dashes or linestyles
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
or linewidths or lw
float or sequence of floats
float or sequence of floats
[None|float|boolean|callable]
[True | False | None]
a url string
[True | False]
any number
In addition to the above described arguments, this function can take a
data keyword argument. If such a data argument is given, the
following arguments are replaced by data[&arg&]:
All positional and all keyword arguments.
matplotlib.pyplot.barh(bottom, width, height=0.8, left=None, hold=None, **kwargs)
Make a horizontal bar plot.
Make a horizontal bar plot with rectangles bounded by:
left, left + width, bottom, bottom + height
(left, right, bottom and top edges)
bottom, width, height, and left can be either scalars
or sequences
Parameters:bottom : scalar or array-like
the y coordinate(s) of the bars
width : scalar or array-like
the width(s) of the bars
height : sequence of scalars, optional, default: 0.8
the heights of the bars
left : sequence of scalars
the x coordinates of the left sides of the bars
Returns: instances.
Other Parameters:
 color : scalar or array-like, optional
the colors of the bars
edgecolor : scalar or array-like, optional
the colors of the bar edges
linewidth : scalar or array-like, optional, default: None
width of bar edge(s). If None, use default
If 0, don’t draw edges.
tick_label : string or array-like, optional, default: None
the tick labels of the bars
xerr : scalar or array-like, optional, default: None
if not None, will be used to generate errorbar(s) on the bar chart
yerr : scalar or array-like, optional, default: None
if not None, will be used to generate errorbar(s) on the bar chart
ecolor : scalar or array-like, optional, default: None
specifies the color of errorbar(s)
capsize : scalar, optional
determines the length in points of the error bar caps
default: None, which will take the value from the
errorbar.capsize .
error_kw :
dictionary of kwargs to be passed to errorbar method. ecolor and
capsize may be specified here rather than as independent kwargs.
align : {‘center’, ‘edge’}, optional
If ‘edge’, aligns bars by their left edges (for vertical
bars) and by their bottom edges (for horizontal bars). If
‘center’, interpret the bottom argument as the
coordinates of the centers of the bars. To align on the
align bars on the top edge pass a negative ‘height’.
log : boolean, optional, default: False
If true, sets the axis to be log scale
Plot a vertical bar plot.
The optional arguments color, edgecolor, linewidth,
xerr, and yerr can be either scalars or sequences of
length equal to the number of bars. This enables you to use
bar as the basis for stacked bar charts, or candlestick plots.
Detail: xerr and yerr are passed directly to
, so they can also have shape 2xN for
independent specification of lower and upper errors.
Other optional kwargs:
float or None
[True | False]
[True | False] or None for default
[‘butt’ | ‘round’ | ‘projecting’]
[True | False]
matplotlib color spec
a callable function
mpl color spec, None, ‘none’, or ‘auto’
mpl color spec, or None for default, or ‘none’ for no color
[True | False]
an id string
[‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]
[‘miter’ | ‘round’ | ‘bevel’]
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float or None for default
[None|float|boolean|callable]
[True | False | None]
a url string
[True | False]
any number
matplotlib.pyplot.bone()
set the default colormap to bone and apply to current image if any.
See help(colormaps) for more information
matplotlib.pyplot.box(on=None)
Turn the axes box on or off. on may be a boolean or a string,
‘on’ or ‘off’.
If on is None, toggle state.
matplotlib.pyplot.boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_xticks=True, autorange=False, zorder=None, hold=None, data=None)
Make a box and whisker plot.
Make a box and whisker plot for each column of x or each
vector in sequence x. The box extends from the lower to
upper quartile values of the data, with a line at the median.
The whiskers extend from the box to show the range of the
data. Flier points are those past the end of the whiskers.
Parameters:x : Array or a sequence of vectors.
The input data.
notch : bool, optional (False)
If True, will produce a notched box plot. Otherwise, a
rectangular boxplot is produced. The notches represent the
confidence interval (CI) around the median. See the entry
for the bootstrap parameter for information regarding
how the locations of the notches are computed.
In cases where the values of the CI are less than the
lower quartile or greater than the upper quartile, the
notches will extend beyond the box, giving it a
distinctive “flipped” appearance. This is expected
behavior and consistent with other statistical
visualization packages.
sym : str, optional
The default symbol for flier points. Enter an empty string
(‘’) if you don’t want to show fliers. If None, then the
fliers default to ‘b+’ If you want more control use the
flierprops kwarg.
vert : bool, optional (True)
If True (default), makes the boxes vertical. If False,
everything is drawn horizontally.
whis : float, sequence, or string (default = 1.5)
As a float, determines the reach of the whiskers to the beyond the
first and third quartiles. In other words, where IQR is the
interquartile range (Q3-Q1), the upper whisker will extend to
last datum less than Q3 + whis*IQR). Similarly, the lower whisker
will extend to the first datum greater than Q1 - whis*IQR.
Beyond the whiskers, data
are considered outliers and are plotted as individual
points. Set this to an unreasonably high value to force the
whiskers to show the min and max values. Alternatively, set
this to an ascending sequence of percentile (e.g., [5, 95])
to set the whiskers at specific percentiles of the data.
Finally, whis can be the string 'range' to force the
whiskers to the min and max of the data.
bootstrap : int, optional
Specifies whether to bootstrap the confidence intervals
around the median for notched boxplots. If bootstrap is
None, no bootstrapping is performed, and notches are
calculated using a Gaussian-based asymptotic approximation
(see McGill, R., Tukey, J.W., and Larsen, W.A., 1978, and
Kendall and Stuart, 1967). Otherwise, bootstrap specifies
the number of times to bootstrap the median to determine its
95% confidence intervals. Values between 1000 and 10000 are
recommended.
usermedians : array-like, optional
An array or sequence whose first dimension (or length) is
compatible with x. This overrides the medians computed
by matplotlib for each element of usermedians that is not
None. When an element of usermedians is None, the median
will be computed by matplotlib as normal.
conf_intervals : array-like, optional
Array or sequence whose first dimension (or length) is
compatible with x and whose second dimension is 2. When
the an element of conf_intervals is not None, the
notch locations computed by matplotlib are overridden
(provided notch is True). When an element of
conf_intervals is None, the notches are computed by the
method specified by the other kwargs (e.g., bootstrap).
positions : array-like, optional
Sets the positions of the boxes. The ticks and limits are
automatically set to match the positions. Defaults to
range(1, N+1) where N is the number of boxes to be drawn.
widths : scalar or array-like
Sets the width of each box either with a scalar or a
sequence. The default is 0.5, or 0.15*(distance between
extreme positions), if that is smaller.
patch_artist : bool, optional (False)
If False produces boxes with the Line2D artist. Otherwise,
boxes and drawn with Patch artists.
labels : sequence, optional
Labels for each dataset. Length must be compatible with
dimensions of x.
manage_xticks : bool, optional (True)
If the function should adjust the xlim and xtick locations.
autorange : bool, optional (False)
When True and the data are distributed such that the 25th and
75th percentiles are equal, whis is set to 'range' such
that the whisker ends are at the minimum and maximum of the
meanline : bool, optional (False)
If True (and showmeans is True), will try to render
the mean as a line spanning the full width of the box
according to meanprops (see below). Not recommended if
shownotches is also True. Otherwise, means will be shown
as points.
zorder : scalar, optional (None)
Sets the zorder of the boxplot.
Returns:result : dict
A dictionary mapping each component of the boxplot to a list
created. That dictionary has the following keys (assuming
vertical boxplots):
boxes: the main body of the boxplot showing the
quartiles and the median’s confidence intervals if
medians: horizontal lines at the median of each box.
whiskers: the vertical lines extending to the most
extreme, non-outlier data points.
caps: the horizontal lines at the ends of the
fliers: points representing data that extend beyond
the whiskers (fliers).
means: points or lines representing the means.
Other Parameters:
 showcaps : bool, optional (True)
Show the caps on the ends of whiskers.
showbox : bool, optional (True)
Show the central box.
showfliers : bool, optional (True)
Show the outliers beyond the caps.
showmeans : bool, optional (False)
Show the arithmetic means.
capprops : dict, optional (None)
Specifies the style of the caps.
boxprops : dict, optional (None)
Specifies the style of the box.
whiskerprops : dict, optional (None)
Specifies the style of the whiskers.
flierprops : dict, optional (None)
Specifies the style of the fliers.
medianprops : dict, optional (None)
Specifies the style of the median.
meanprops : dict, optional (None)
Specifies the style of the mean.
In addition to the above described arguments, this function can take a
data keyword argument. If such a data argument is given, the
following arguments are replaced by data[&arg&]:
All positional and all keyword arguments.
matplotlib.pyplot.broken_barh(xranges, yrange, hold=None, data=None, **kwargs)
Plot horizontal bars.
A collection of horizontal bars spanning yrange with a sequence of
Required arguments:
sequence of (xmin, xwidth)
sequence of (ymin, ywidth)
kwargs are
properties:
float or None
[True | False]
or antialiaseds
Boolean or sequence of booleans
a length 2 sequence of floats
[True | False]
a colormap or registered colormap name
matplotlib color arg or sequence of rgba tuples
a callable function
or edgecolors
matplotlib color spec or sequence of specs
or facecolors
matplotlib color spec or sequence of specs
an id string
[ ‘/’ | ‘\’ | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’ ]
string or anything printable with ‘%s’ conversion.
or dashes or linestyles
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
or linewidths or lw
float or sequence of floats
float or sequence of floats
[None|float|boolean|callable]
[True | False | None]
a url string
[True | False]
any number
these can either be a single argument, i.e.,:
facecolors = 'black'
or a sequence of arguments for the various bars, i.e.,:
facecolors = ('black', 'red', 'green')
In addition to the above described arguments, this function can take a
data keyword argument. If such a data argument is given, the
following arguments are replaced by data[&arg&]:
All positional and all keyword arguments.
matplotlib.pyplot.cla()
Clear the current axes.
matplotlib.pyplot.clabel(CS, *args, **kwargs)
Label a contour plot.
Call signature:
clabel(cs, **kwargs)
Adds labels to line contours in cs, where cs is a
ContourSet object returned by
clabel(cs, v, **kwargs)
only labels contours listed in v.
Optional keyword arguments:
size in points or relative size e.g., ‘smaller’, ‘x-large’
if None, the color of each label matches the color of
the corresponding contour
if one string color, e.g., colors = ‘r’ or colors =
‘red’, all labels will be plotted in this color
if a tuple of matplotlib color args (string, float, rgb, etc),
different labels will be plotted in different colors in the order
controls whether the underlying contour is removed or
not. Default is True.
inline_spacing:
space in pixels to leave on each side of label when
placing inline. Defaults to 5. This spacing will be
exact for labels at locations where the contour is
straight, less so for labels on curved contours.
a format string for the label. Default is &#f’
Alternatively, this can be a dictionary matching contour
levels with arbitrary strings to use for each contour level
(i.e., fmt[level]=string), or it can be any callable, such
instance, that
returns a string when called with a numeric contour level.
if True, contour labels will be placed manually using
mouse clicks. Click the first button near a contour to
add a label, click the second button (or potentially both
mouse buttons at once) to finish adding labels. The third
button can be used to remove the last label added, but
only if labels are not inline. Alternatively, the keyboard
can be used to select label locations (enter to end label
placement, delete or backspace act like the third mouse button,
and any other key will select a label location).
manual can be an iterable object of x,y tuples. Contour labels
will be created as if mouse is clicked at each x,y positions.
rightside_up:
if True (default), label rotations will always be plus
or minus 90 degrees from level.
use_clabeltext:
if True (default is False), ClabelText class (instead of
matplotlib.Text) is used to create labels. ClabelText
recalculates rotation angles of texts during the drawing time,
therefore this can be used if aspect of the axes changes.
matplotlib.pyplot.clf()
Clear the current figure.
matplotlib.pyplot.clim(vmin=None, vmax=None)
Set the color limits of the current image.
To apply clim to all axes images do:
clim(0, 0.5)
If either vmin or vmax is None, the image min/max respectively
will be used for color scaling.
If you want to set the clim of multiple images,
use, for example:
for im in gca().get_images():
im.set_clim(0, 0.05)
matplotlib.pyplot.close(*args)
Close a figure window.
close() by itself closes the current figure
close(h) where h is a Figure instance, closes that figure
close(num) closes figure number num
close(name) where name is a string, closes figure with that label
close('all') closes all the figure windows
matplotlib.pyplot.cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend=&function detrend_none&, window=&function window_hanning&, noverlap=0, pad_to=None, sides='default', scale_by_freq=None, hold=None, data=None, **kwargs)
Plot the coherence between x and y.
Plot the coherence between x and y. Coherence is the
normalized cross spectral density:
Parameters:Fs : scalar
The sampling frequency (samples per time unit). It is used
to calculate the Fourier frequencies, freqs, in cycles per time
unit. The default value is 2.
window : callable or ndarray
A function or a vector of length NFFT. To create window
vectors see window_hanning(), window_none(),
numpy.blackman(), numpy.hamming(),
numpy.bartlett(), scipy.signal(),
scipy.signal.get_window(), etc. The default is
window_hanning(). If a function is passed as the
argument, it must take a data segment as an argument and
return the windowed version of the segment.
sides : [ ‘default’ | ‘onesided’ | ‘twosided’ ]
Specifies which sides of the spectrum to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. ‘onesided’ forces the return of a one-sided
spectrum, while ‘twosided’ forces two-sided.
pad_to : integer
The number of points to which the data segment is padded when
performing the FFT. This can be different from NFFT, which
specifies the number of data points used. While not increasing
the actual resolution of the spectrum (the minimum distance between
resolvable peaks), this can give more points in the plot,
allowing for more detail. This corresponds to the n parameter
in the call to fft(). The default is None, which sets pad_to
equal to NFFT
NFFT : integer
The number of data points used in each block for the FFT.
A power 2 is most efficient. The default value is 256.
This should NOT be used to get zero padding, or the scaling of the
result will be incorrect. Use pad_to for this instead.
detrend : {‘default’, ‘constant’, ‘mean’, ‘linear’, ‘none’} or callable
The function applied to each segment before fft-ing,
designed to remove the mean or linear trend. Unlike in
MATLAB, where the detrend parameter is a vector, in
matplotlib is it a function. The pylab
module defines detrend_none(),
detrend_mean(), and
detrend_linear(), but you can use
a custom function as well. You can also use a string to choose
one of the functions. ‘default’, ‘constant’, and ‘mean’ call
detrend_mean(). ‘linear’ calls
detrend_linear(). ‘none’ calls
detrend_none().
scale_by_freq : boolean, optional
Specifies whether the resulting density values should be scaled
by the scaling frequency, which gives density in units of Hz^-1.
This allows for integration over the returned frequency values.
The default is True for MATLAB compatibility.
noverlap : integer
The number of points of overlap between blocks. The
default value is 0 (no overlap).
Fc : integer
The center frequency of x (defaults to 0), which offsets
the x extents of the plot to reflect the frequency range used
when a signal is acquired and then filtered and downsampled to
**kwargs :
Keyword arguments control the
properties of the coherence plot:
float (0.0 transparent through 1.0 opaque)
[True | False]
[True | False]
[True | False]
any matplotlib color
a callable function
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
sequence of on/off ink in points
[‘default’ | ‘steps’ | ‘steps-pre’ | ‘steps-mid’ | ‘steps-post’]
[‘full’ | ‘left’ | ‘right’ | ‘bottom’ | ‘top’ | ‘none’]
an id string
string or anything printable with ‘%s’ conversion.
[‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
float value in points
any matplotlib color
float value in points
any matplotlib color
any matplotlib color
[None | int | length-2 tuple of int | slice | list/array of int | float | length-2 tuple of float]
float distance in points or callable pick function fn(artist, event)
float distance in points
[True | False | None]
[‘butt’ | ‘round’ | ‘projecting’]
[‘miter’ | ‘round’ | ‘bevel’]
a url string
[True | False]
any number
Returns:The return value is a tuple (Cxy, f), where f are the
frequencies of the coherence vector.
kwargs are applied to the lines.
References
Bendat & Piersol – Random Data: Analysis and Measurement Procedures,
John Wiley & Sons (1986)
In addition to the above described arguments, this function can take a
data keyword argument. If such a data argument is given, the
following arguments are replaced by data[&arg&]:
All arguments with the following names: ‘x’, ‘y’.
matplotlib.pyplot.colorbar(mappable=None, cax=None, ax=None, **kw)
Add a colorbar to a plot.
Function signature all
but the first are also method signatures for the
colorbar(**kwargs)
colorbar(mappable, **kwargs)
colorbar(mappable, cax=cax, **kwargs)
colorbar(mappable, ax=ax, **kwargs)
arguments:
the Image,
ContourSet, etc. to
this argument is mandatory for the
method but optional for the
function, which sets the
default to the current image.
keyword arguments:
None | axes object into which the colorbar will be drawn
None | parent axes object(s) from which space for a new
colorbar axes will be stolen. If a list of axes is given
they will all be resized to make room for the colorbar axes.
use_gridspec
False | If cax is None, a new cax is created as an instance of
Axes. If ax is an instance of Subplot and use_gridspec is True,
cax is created as an instance of Subplot using the
grid_spec module.
Additional keyword arguments are of two kinds:
axes properties:
orientation
vertical or horizontal
0.15; fraction of original axes to use for colorbar
0.05 if vertical, 0.15 fraction
of original axes between colorbar and new image axes
1.0; fraction by which to shrink the colorbar
20; ratio of long to short dimensions
(0.0, 0.5) (0.5, 1.0)
the anchor point of the colorbar axes
(1.0, 0.5) (0.5, 0.0)
the anchor point of the colorbar parent axes. If
False, the parent axes’ anchor will be unchanged
colorbar properties:
[ ‘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 s}

我要回帖

更多关于 matlab中handles 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信