Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9690232

Browse files
committed
Merge pull request#1795 from NelleV/MEP10_hvlines
MEP10 - refactored hlines and vlines documentation
2 parents946ffad +0de3de8 commit9690232

File tree

6 files changed

+88
-83
lines changed

6 files changed

+88
-83
lines changed

‎examples/pylab_examples/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Here are some demos of how to use the matplotlib.
1313

1414
-- subplot_demo.py - how to do multiple axes on a single plot
1515

16-
--vline_demo.py - working with straight lines
16+
--vline_hline_demo.py - working with straight lines
1717

1818
-- stock_demo.py - working with large datasets. Click on the plot and
1919
launch the navigation tool; wheel mouse over the navigation

‎examples/pylab_examples/hline_demo.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎examples/pylab_examples/vline_demo.py

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Small demonstration of the hlines and vlines plots.
5+
"""
6+
7+
frommatplotlibimportpyplotasplt
8+
fromnumpyimportsin,exp,absolute,pi,arange
9+
fromnumpy.randomimportnormal
10+
11+
12+
deff(t):
13+
s1=sin(2*pi*t)
14+
e1=exp(-t)
15+
returnabsolute((s1*e1))+.05
16+
17+
18+
t=arange(0.0,5.0,0.1)
19+
s=f(t)
20+
nse=normal(0.0,0.3,t.shape)*s
21+
22+
fig=plt.figure(figsize=(12,6))
23+
vax=fig.add_subplot(121)
24+
hax=fig.add_subplot(122)
25+
26+
vax.plot(t,s+nse,'b^')
27+
vax.vlines(t, [0],s)
28+
vax.set_xlabel('time (s)')
29+
vax.set_title('Vertical lines demo')
30+
31+
hax.plot(s+nse,t,'b^')
32+
hax.hlines(t, [0],s,lw=2)
33+
hax.set_xlabel('time (s)')
34+
hax.set_title('Horizontal lines demo')
35+
36+
plt.show()

‎examples/tests/backend_driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
'hist_colormapped.py',
114114
'histogram_demo.py',
115115
'histogram_demo_extended.py',
116-
'hline_demo.py',
116+
'vline_hline_demo.py',
117117

118118
'image_clip_path.py',
119119
'image_demo.py',
@@ -199,7 +199,6 @@
199199
'transoffset.py',
200200
'unicode_demo.py',
201201
'vertical_ticklabels.py',
202-
'vline_demo.py',
203202
'xcorr_demo.py',
204203
'zorder_demo.py',
205204
]

‎lib/matplotlib/axes.py

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,37 +3656,39 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
36563656
"""
36573657
Plot horizontal lines.
36583658
3659-
call signature::
3660-
3661-
hlines(y, xmin, xmax, colors='k', linestyles='solid', **kwargs)
3659+
Plot horizontal lines at each `y` from `xmin` to `xmax`.
36623660
3663-
Plot horizontal lines at each *y* from *xmin* to *xmax*.
3661+
Parameters
3662+
----------
3663+
y : scalar or 1D array_like
3664+
y-indexes where to plot the lines.
36643665
3665-
Returns the :class:`~matplotlib.collections.LineCollection`
3666-
that was added.
3666+
xmin, xmax : scalar or 1D array_like
3667+
Respective beginning and end of each line. If scalars are
3668+
provided, all lines will have same length.
36673669
3668-
Required arguments:
3670+
colors : array_like of colors, optional, default: 'k'
36693671
3670-
*y*:
3671-
a 1-D numpy array or iterable.
3672+
linestyles : ['solid' | 'dashed' | 'dashdot' | 'dotted'], optional
36723673
3673-
*xmin* and *xmax*:
3674-
can be scalars or ``len(x)`` numpy arrays. If they are
3675-
scalars, then the respective values are constant, else the
3676-
widths of the lines are determined by *xmin* and *xmax*.
3674+
label : string, optional, default: ''
36773675
3678-
Optional keyword arguments:
3676+
Returns
3677+
-------
3678+
lines : `~matplotlib.collections.LineCollection`
36793679
3680-
*colors*:
3681-
a line collections color argument, either a single color
3682-
or a ``len(y)`` list of colors
3680+
Other parameters
3681+
----------------
3682+
kwargs : `~matplotlib.collections.LineCollection` properties.
36833683
3684-
*linestyles*:
3685-
[ 'solid' | 'dashed' | 'dashdot' | 'dotted' ]
3684+
See also
3685+
--------
3686+
vlines : vertical lines
36863687
3687-
**Example:**
3688+
Examples
3689+
--------
3690+
.. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
36883691
3689-
.. plot:: mpl_examples/pylab_examples/hline_demo.py
36903692
"""
36913693

36923694
# We do the conversion first since not all unitized data is uniform
@@ -3743,27 +3745,39 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
37433745
"""
37443746
Plot vertical lines.
37453747
3746-
Call signature::
3748+
Plot vertical lines at each `x` from `ymin` to `ymax`.
37473749
3748-
vlines(x, ymin, ymax, color='k', linestyles='solid')
3750+
Parameters
3751+
----------
3752+
x : scalar or 1D array_like
3753+
x-indexes where to plot the lines.
37493754
3750-
Plot vertical lines at each *x* from *ymin* to *ymax*. *ymin*
3751-
or *ymax* can be scalars or len(*x*) numpy arrays. If they are
3752-
scalars, then the respective values are constant, else the
3753-
heights of the lines are determined by *ymin* and *ymax*.
3755+
xmin, xmax : scalar or 1D array_like
3756+
Respective beginning and end of each line. If scalars are
3757+
provided, all lines will have same length.
37543758
3755-
*colors* :
3756-
A line collection's color args, either a single color
3757-
or a ``len(x)`` list of colors
3759+
colors : array_like of colors, optional, default: 'k'
37583760
3759-
*linestyles* : ['solid' | 'dashed' | 'dashdot' | 'dotted' ]
3761+
linestyles : ['solid' | 'dashed' | 'dashdot' | 'dotted'], optional
37603762
3761-
Returns the :class:`matplotlib.collections.LineCollection`
3762-
that was added.
3763+
label : string, optional, default: ''
37633764
3764-
kwargs are :class:`~matplotlib.collections.LineCollection` properties:
3765+
Returns
3766+
-------
3767+
lines : `~matplotlib.collections.LineCollection`
3768+
3769+
Other parameters
3770+
----------------
3771+
kwargs : `~matplotlib.collections.LineCollection` properties.
3772+
3773+
See also
3774+
--------
3775+
hlines : horizontal lines
3776+
3777+
Examples
3778+
---------
3779+
.. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
37653780
3766-
%(LineCollection)s
37673781
"""
37683782

37693783
self._process_unit_info(xdata=x,ydata=[ymin,ymax],kwargs=kwargs)
@@ -8403,7 +8417,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
84038417
# For normed data, set to log base * minimum data value
84048418
# (gives 1 full tick-label unit for the lowest filled bin)
84058419
ndata=np.array(n)
8406-
minimum= (np.min(ndata[ndata>0]))/logbase
8420+
minimum= (np.min(ndata[ndata>0]))/logbase
84078421
else:
84088422
# For non-normed data, set the min to log base,
84098423
# again so that there is 1 full tick-label unit

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp