Skip to content

Commit 58458de

Browse files
committed
Modified hline and vline examples to have only one file and linked them to the documentation
1 parent 4c23c38 commit 58458de

File tree

6 files changed

+43
-48
lines changed

6 files changed

+43
-48
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+
from matplotlib import pyplot as plt
8+
from numpy import sin, exp, absolute, pi, arange
9+
from numpy.random import normal
10+
11+
12+
def f(t):
13+
s1 = sin(2 * pi * t)
14+
e1 = exp(-t)
15+
return absolute((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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3681,7 +3681,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
36813681
36823682
Example
36833683
--------
3684-
.. plot:: mpl_examples/pylab_examples/hline_demo.py
3684+
.. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
36853685
36863686
See also
36873687
--------
@@ -3765,6 +3765,10 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
37653765
-------
37663766
:class:`~matplotlib.collections.LineCollection`
37673767
3768+
Example
3769+
-------
3770+
.. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
3771+
37683772
See also
37693773
--------
37703774
hlines : horizontal lines

0 commit comments

Comments
 (0)