Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified hline and vline examples to have only one file and linked th…

…em to the documentation
  • Loading branch information...
commit 58458de1a5a849a2b40751d417bd3412a1074ff2 1 parent 4c23c38
@NelleV authored
View
2  examples/pylab_examples/README
@@ -13,7 +13,7 @@ Here are some demos of how to use the matplotlib.
-- subplot_demo.py - how to do multiple axes on a single plot
--- vline_demo.py - working with straight lines
+-- vline_hline_demo.py - working with straight lines
-- stock_demo.py - working with large datasets. Click on the plot and
launch the navigation tool; wheel mouse over the navigation
View
23 examples/pylab_examples/hline_demo.py
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-import numpy as np
-import matplotlib.pyplot as plt
-
-def f(t):
- s1 = np.sin(2*np.pi*t)
- e1 = np.exp(-t)
- return np.absolute((s1*e1))+.05
-
-
-t = np.arange(0.0, 5.0, 0.1)
-s = f(t)
-nse = np.random.normal(0.0, 0.3, t.shape) * s
-
-
-plt.plot(s+nse, t, 'b^')
-plt.hlines(t, [0], s, lw=2)
-plt.xlabel('time (s)')
-plt.title('Comparison of model with data')
-
-plt.xlim(xmin=0)
-plt.show()
-
View
21 examples/pylab_examples/vline_demo.py
@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-from matplotlib.pyplot import *
-from numpy import sin, exp, absolute, pi, arange
-from numpy.random import normal
-
-def f(t):
- s1 = sin(2*pi*t)
- e1 = exp(-t)
- return absolute((s1*e1))+.05
-
-
-t = arange(0.0, 5.0, 0.1)
-s = f(t)
-nse = normal(0.0, 0.3, t.shape) * s
-
-plot(t, s+nse, 'b^')
-vlines(t, [0], s)
-xlabel('time (s)')
-title('Comparison of model with data')
-show()
-
View
36 examples/pylab_examples/vline_hline_demo.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+"""
+Small demonstration of the hlines and vlines plots.
+"""
+
+from matplotlib import pyplot as plt
+from numpy import sin, exp, absolute, pi, arange
+from numpy.random import normal
+
+
+def f(t):
+ s1 = sin(2 * pi * t)
+ e1 = exp(-t)
+ return absolute((s1 * e1)) + .05
+
+
+t = arange(0.0, 5.0, 0.1)
+s = f(t)
+nse = normal(0.0, 0.3, t.shape) * s
+
+fig = plt.figure(figsize=(12, 6))
+vax = fig.add_subplot(121)
+hax = fig.add_subplot(122)
+
+vax.plot(t, s + nse, 'b^')
+vax.vlines(t, [0], s)
+vax.set_xlabel('time (s)')
+vax.set_title('Vertical lines demo')
+
+hax.plot(s + nse, t, 'b^')
+hax.hlines(t, [0], s, lw=2)
+hax.set_xlabel('time (s)')
+hax.set_title('Horizontal lines demo')
+
+plt.show()
View
3  examples/tests/backend_driver.py
@@ -113,7 +113,7 @@
'hist_colormapped.py',
'histogram_demo.py',
'histogram_demo_extended.py',
- 'hline_demo.py',
+ 'vline_hline_demo.py',
'image_clip_path.py',
'image_demo.py',
@@ -199,7 +199,6 @@
'transoffset.py',
'unicode_demo.py',
'vertical_ticklabels.py',
- 'vline_demo.py',
'xcorr_demo.py',
'zorder_demo.py',
]
View
6 lib/matplotlib/axes.py
@@ -3681,7 +3681,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
Example
--------
- .. plot:: mpl_examples/pylab_examples/hline_demo.py
+ .. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
See also
--------
@@ -3765,6 +3765,10 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
-------
:class:`~matplotlib.collections.LineCollection`
+ Example
+ -------
+ .. plot:: mpl_examples/pylab_examples/vline_hline_demo.py
+
See also
--------
hlines : horizontal lines
Please sign in to comment.
Something went wrong with that request. Please try again.