[Tutor] How do I plot a horizontal line and a vertical line in python

Mkhanyisi Madlavana mmadlavana at gmail.com
Fri Dec 4 13:17:27 CET 2009

How can I do this using matplotlib? The snippet of my code looks like:

k = 1.195*ones((1,data[0].size))
plot(data[0], k,'--')

but I get this error:
Traceback (most recent call last):
  File "./plot_detector.py", line 26, in <module>
    plot(data[0], k,'--')
  File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 2142, in plot
    ret = ax.plot(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 3418, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 297, in
    for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 274, in
    x, y = self._xy_from_xy(x, y)
  File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 214, in
    raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

Am I doing this all the wrong way?


More information about the Tutor mailing list