[chaco][BUG?] contour_plot issue...

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[chaco][BUG?] contour_plot issue...

fred-2
Hi all,

I struggle against an issue, using basic contour_plot.py.

Let's say I want to draw line contours (second plot.contour_plot()) in
pink color:

     plot.contour_plot("imagedata",
                       type="line",
                       xbounds=(xs[0], xs[-1]),
                       ybounds=(ys[0], ys[-1]),
                       colormap=pink)

Line contours are still black.

So I tried:


     plot.contour_plot("imagedata",
                       type="line",
                       xbounds=(xs[0], xs[-1]),
                       ybounds=(ys[0], ys[-1]),
                       colors=pink)

In this case, I get a traceback:

enthought.traits.trait_errors.TraitError: The 'colors' trait of a
ContourLinePlot instance must be a string or a ColorMapper or None or a
list of items which are any value or a tuple, but a value of
<enthought.chaco.color_mapper.ColorMapper object at 0x36fc290> <class
'enthought.chaco.color_mapper.ColorMapper'> was specified.

So I looked at base_contour_plot.py, line 27:

     # The color(s) of the lines.
     colors = Trait(None, Str, Instance("ColorMapper"), List, Tuple)

In previous versions, it was

     colors = Trait(None, Str, Instance(ColorMapper), List, Tuple)

If I remove " around ColorMapper, it works fine with 'colors=pink' (but
line contours are still black with 'colormap=pink).


Any clue?


TIA


Cheers,

PS : I use svn sources #26042

--
Fred

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

contour_plot.py (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [chaco][BUG?] contour_plot issue...

John Wiggins
Fred,

Removing the quotes around ColorMapper on lines 27 and 30 is a good solution. I'll make that change to the code soon. Note that "colormap" is not a trait of contour plots or a kwarg for the contour_plot() method, so passing it in will have no effect. I'll fix the example code to reflect that as well.

Unfortunately, that doesn't answer why this was broken to begin with. I'm not the best person to answer that since my knowledge of Traits isn't very deep. Here's what I did find:
1) Not creating a poly contour plot in the basic/contour_plot.py example will cause the TraitError to go away.
2) Changing the Trait declaration from
    colors = Trait(None, Str, Instance("ColorMapper"), List, Tuple)
    to
    colors = Instance("ColorMapper")
    also causes the TraitError to go away.
3) I think the above has something to do with the trait declaration on line 30:
    color_mapper = Property(Instance("ColorMapper"))
    which gets used when you create a contour poly plot (and the "colors" trait is not used)

If somebody with deeper Traits knowledge sees the problem here, it'd be good to know what it is.

- John

On Wed, Dec 1, 2010 at 8:40 AM, Fred <[hidden email]> wrote:
Hi all,

I struggle against an issue, using basic contour_plot.py.

Let's say I want to draw line contours (second plot.contour_plot()) in pink color:

   plot.contour_plot("imagedata",
                     type="line",
                     xbounds=(xs[0], xs[-1]),
                     ybounds=(ys[0], ys[-1]),
                     colormap=pink)

Line contours are still black.

So I tried:


   plot.contour_plot("imagedata",
                     type="line",
                     xbounds=(xs[0], xs[-1]),
                     ybounds=(ys[0], ys[-1]),
                     colors=pink)

In this case, I get a traceback:

enthought.traits.trait_errors.TraitError: The 'colors' trait of a ContourLinePlot instance must be a string or a ColorMapper or None or a list of items which are any value or a tuple, but a value of <enthought.chaco.color_mapper.ColorMapper object at 0x36fc290> <class 'enthought.chaco.color_mapper.ColorMapper'> was specified.

So I looked at base_contour_plot.py, line 27:

   # The color(s) of the lines.
   colors = Trait(None, Str, Instance("ColorMapper"), List, Tuple)

In previous versions, it was

   colors = Trait(None, Str, Instance(ColorMapper), List, Tuple)

If I remove " around ColorMapper, it works fine with 'colors=pink' (but line contours are still black with 'colormap=pink).


Any clue?


TIA


Cheers,

PS : I use svn sources #26042

--
Fred

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [chaco][BUG?] contour_plot issue...

fred-2
Le 01/12/2010 17:55, John Wiggins a écrit :
> Fred,
>
> Removing the quotes around ColorMapper on lines 27 and 30 is a good
> solution. I'll make that change to the code soon. Note that "colormap"
> is not a trait of contour plots or a kwarg for the contour_plot()
> method, so passing it in will have no effect. I'll fix the example code
> to reflect that as well.
Thanks, John!

Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev