Problem with dashes

Hello, I've just discovered matplotlib-0.40 (with linux),

    > and going through the tutorial, I get an error (pasted at
    > the end of email) when using dashes in the "Multiple lines
    > with one plot command" example.

This script runs on my system

   from matplotlib.matlab import *
   t = array([0,1,2,3], Float)
   plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
   show()

/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtk.py in
set_dashes(self, dash_offset, dash_list)
    175 dpi = self.drawable.dpi.get()
    176 if dash_list is not None:
--> 177 dashes = dash_list*dpi/72.0
    178 self.gdkGC.line_style = gdk.LINE_ON_OFF_DASH
    179 dl = [int(math.ceil(val)) for val in dash_list]

TypeError: unsupported operand type(s) for /: 'array' and 'float'

This looks a lot like a known bug with

from __future__ import division

and use of the division / operator with Numeric arrays. For that
reason I usually try and write

   dashes = dpi/72.0*dash_list

or

   dashes = dash_list*(dpi/72.0)

Apparently I forgot this time. Try the above and see if they help.
Please let me know.

John Hunter

Yes, it now works fine, thank you !

Y

···

On Sat, 17 Jan 2004, John Hunter wrote:

and use of the division / operator with Numeric arrays. For that
reason I usually try and write

   dashes = dpi/72.0*dash_list

or

   dashes = dash_list*(dpi/72.0)

Apparently I forgot this time. Try the above and see if they help.
Please let me know.