Chaco: line plot area color

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

Chaco: line plot area color

Fabio Pliger
Le 19/05/2010 17:07, Fabio Pliger a écrit :
> Hi
>
> Is there any way set the color of the area under a line plot? I've
> searched around but didn't find a way. I remember that with old version
> of chaco it was possibile... it still possible?
You can look at financial_plot.py example.

HTH

On 05/19/2010 10:07 AM, Fabio Pliger wrote:
> Hi
>
> Is there any way set the color of the area under a line plot? I've
> searched around but didn't find a way. I remember that with old
> version of chaco it was possibile... it still possible?
>

You probably want to use the FilledLinePlot. Its not a full featured as
the LinePlot, though it should be adequate.
 
Thanks for your answer. Unfortunately my case is a little bit more complicated than the financial_plot example.

I have a Plot container with 2 plot instances that have their index_range connected and share the same ArrayPlotData as datasource. On each Plot i have a random number of curves ( created by a plot.plot( ... ) call )that can be "modified" into a scattered, line ad stepped line "under" plots. What i'd like to do is to enable the user to "check" an option ( let's say "fill_area" ) so the area under each single line_plot is shown or not..
I've looked into the Plot.plot method and it seems that the plot type "polygon" should be supported and as the FilledLinePlot inherits from it I hope it shouldn't be too hard to extend the plot method to support the FilledLinePlot type too. This make sense to you or you see any other easier way?

cheers

FP

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

Re: Chaco: line plot area color

bryce hendrix-2
On 05/19/2010 11:40 AM, Fabio Pliger wrote:
Le 19/05/2010 17:07, Fabio Pliger a écrit :
> Hi
>
> Is there any way set the color of the area under a line plot? I've

> searched around but didn't find a way. I remember that with old version
> of chaco it was possibile... it still possible?
You can look at financial_plot.py example.

HTH

    
On 05/19/2010 10:07 AM, Fabio Pliger wrote:
> Hi
>

> Is there any way set the color of the area under a line plot? I've 
> searched around but didn't find a way. I remember that with old 
> version of chaco it was possibile... it still possible?

>

You probably want to use the FilledLinePlot. Its not a full featured as 
the LinePlot, though it should be adequate.
    
 
Thanks for your answer. Unfortunately my case is a little bit more complicated than the financial_plot example.

I have a Plot container with 2 plot instances that have their index_range connected and share the same ArrayPlotData as datasource. On each Plot i have a random number of curves ( created by a plot.plot( ... ) call )that can be "modified" into a scattered, line ad stepped line "under" plots. What i'd like to do is to enable the user to "check" an option ( let's say "fill_area" ) so the area under each single line_plot is shown or not..
I've looked into the Plot.plot method and it seems that the plot type "polygon" should be supported and as the FilledLinePlot inherits from it I hope it shouldn't be too hard to extend the plot method to support the FilledLinePlot type too. This make sense to you or you see any other easier way?

What I would do is: for each series, make 3 plots (scatter, line and filled line), then change the visibility of each depending on the desired effect. As for how to use Plot.plot() and the line plot, you have 2 options. If you're using a svn checkout of Chaco, there is a method add_xy_plot which allows for your to specify the renderer class. If you're using an older version, here is the hack I've used in the past:

class MyPlot(Plot):
    renderer_map={'line':LinePlot, 'scatter':ScatterPlot, 'polygon':FilledLinePlot}

then when you want to create the filled line plot, call my_plot.plot(..., type='polygon'). This hack works fine as long as you want to change the plot type for one of the types the plot() method accepts, but its limited if you want to use similar types simultaneously, for instance, PolygonPlot and FilledLinePlot.

Bryce

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

Re: Chaco: line plot area color

Fabio Pliger
2010/5/19 bryce hendrix <[hidden email]>
On 05/19/2010 11:40 AM, Fabio Pliger wrote:
 
Thanks for your answer. Unfortunately my case is a little bit more complicated than the financial_plot example.

I have a Plot container with 2 plot instances that have their index_range connected and share the same ArrayPlotData as datasource. On each Plot i have a random number of curves ( created by a plot.plot( ... ) call )that can be "modified" into a scattered, line ad stepped line "under" plots. What i'd like to do is to enable the user to "check" an option ( let's say "fill_area" ) so the area under each single line_plot is shown or not..
I've looked into the Plot.plot method and it seems that the plot type "polygon" should be supported and as the FilledLinePlot inherits from it I hope it shouldn't be too hard to extend the plot method to support the FilledLinePlot type too. This make sense to you or you see any other easier way?

What I would do is: for each series, make 3 plots (scatter, line and filled line), then change the visibility of each depending on the desired effect. As for how to use Plot.plot() and the line plot, you have 2 options. If you're using a svn checkout of Chaco, there is a method add_xy_plot which allows for your to specify the renderer class. If you're using an older version, here is the hack I've used in the past:

class MyPlot(Plot):
    renderer_map={'line':LinePlot, 'scatter':ScatterPlot, 'polygon':FilledLinePlot}

then when you want to create the filled line plot, call my_plot.plot(..., type='polygon'). This hack works fine as long as you want to change the plot type for one of the types the plot() method accepts, but its limited if you want to use similar types simultaneously, for instance, PolygonPlot and FilledLinePlot.

Thanks Bryce for your answer. I've just use the hack as it's quickier in my code ( i've just added this line: plot.renderer_map. = {'line':LinePlot, 'scatter':ScatterPlot, 'polygon':FilledLinePlot} ) and works like a charm! But now i've come to this issue. FilledLinePlot does not support a render style such as connectedhold wich is the way i need to draw it. I've tryied to hack the _render method getting the idea from the LinePlot._render_connected_hold method, but I suppose that gc.lines is just not behave like gc.line_set and gc.fill_path(). Any hint on this? :)

thanks

FP

--
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.

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

Re: Chaco: line plot area color

Fabio Pliger
Any hint on that?


2010/5/23 Fabio Pliger <[hidden email]>
2010/5/19 bryce hendrix <[hidden email]>
On 05/19/2010 11:40 AM, Fabio Pliger wrote:
 
Thanks for your answer. Unfortunately my case is a little bit more complicated than the financial_plot example.

I have a Plot container with 2 plot instances that have their index_range connected and share the same ArrayPlotData as datasource. On each Plot i have a random number of curves ( created by a plot.plot( ... ) call )that can be "modified" into a scattered, line ad stepped line "under" plots. What i'd like to do is to enable the user to "check" an option ( let's say "fill_area" ) so the area under each single line_plot is shown or not..
I've looked into the Plot.plot method and it seems that the plot type "polygon" should be supported and as the FilledLinePlot inherits from it I hope it shouldn't be too hard to extend the plot method to support the FilledLinePlot type too. This make sense to you or you see any other easier way?

What I would do is: for each series, make 3 plots (scatter, line and filled line), then change the visibility of each depending on the desired effect. As for how to use Plot.plot() and the line plot, you have 2 options. If you're using a svn checkout of Chaco, there is a method add_xy_plot which allows for your to specify the renderer class. If you're using an older version, here is the hack I've used in the past:

class MyPlot(Plot):
    renderer_map={'line':LinePlot, 'scatter':ScatterPlot, 'polygon':FilledLinePlot}

then when you want to create the filled line plot, call my_plot.plot(..., type='polygon'). This hack works fine as long as you want to change the plot type for one of the types the plot() method accepts, but its limited if you want to use similar types simultaneously, for instance, PolygonPlot and FilledLinePlot.

Thanks Bryce for your answer. I've just use the hack as it's quickier in my code ( i've just added this line: plot.renderer_map. = {'line':LinePlot, 'scatter':ScatterPlot, 'polygon':FilledLinePlot} ) and works like a charm! But now i've come to this issue. FilledLinePlot does not support a render style such as connectedhold wich is the way i need to draw it. I've tryied to hack the _render method getting the idea from the LinePlot._render_connected_hold method, but I suppose that gc.lines is just not behave like gc.line_set and gc.fill_path(). Any hint on this? :)

thanks

FP

--
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.



--
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.

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

Re: Chaco: line plot area color

Peter Wang
OK, I've checked in a modification to FilledLinePlot so that it now
supports "hold" and "connectedhold" styles.  If you are using an SVN
checkout of Chaco, then just do an update.  If not, then you will need
to update filled_line_plot.py and line_plot.py in your installed
version of Chaco from the ones in SVN:
https://svn.enthought.com/enthought/browser/Chaco/trunk/enthought/chaco/filled_line_plot.py
https://svn.enthought.com/enthought/browser/Chaco/trunk/enthought/chaco/lineplot.py


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