fill step plots

Hi; I've got a rather simple question. I want to (color) fill a step plot below the line, but using the fill() function always creates regular plots, not step plots, and fillstyle doesn't work as I'd expect it to. How can I fill a step plot? Something like this:

import matplotlib.pyplot as plt
x = [0.0,0.5,0.66,0.75,1.0]
y = [0.72,0.72,0.61,0.43,0.33]
plt.step(x, y, fillstyle="bottom") # doesn't work how I imagine...
plt.axis([0.0,1.0,0.0,1.0])
plt.show()

What I want is that the area below the step-plot line is color-filled, but I seem to be unable to find a function for it. If I use plt.fill(), it creates a polygon plot and it does not allow to use the kwarg drawstyle="steps", so I get no further with this function either.

I guess it's a simple problem, but I'm having a bit of a hard time wading though all the API, being completely new to matplotlib, so some help would be very welcome!
--Florian

**NOTA DE CONFIDENCIALIDAD** Este correo electr�nico, y en su caso los ficheros adjuntos, pueden contener informaci�n protegida para el uso exclusivo de su destinatario. Se proh�be la distribuci�n, reproducci�n o cualquier otro tipo de transmisi�n por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido.
**CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies.

Florian Leitner wrote:

Hi; I've got a rather simple question. I want to (color) fill a step plot below the line, but using the fill() function always creates regular plots, not step plots, and fillstyle doesn't work as I'd expect it to. How can I fill a step plot? Something like this:

import matplotlib.pyplot as plt
x = [0.0,0.5,0.66,0.75,1.0]
y = [0.72,0.72,0.61,0.43,0.33]
plt.step(x, y, fillstyle="bottom") # doesn't work how I imagine...
plt.axis([0.0,1.0,0.0,1.0])
plt.show()

What I want is that the area below the step-plot line is color-filled, but I seem to be unable to find a function for it. If I use plt.fill(), it creates a polygon plot and it does not allow to use the kwarg drawstyle="steps", so I get no further with this function either.

I guess it's a simple problem, but I'm having a bit of a hard time wading though all the API, being completely new to matplotlib, so some help would be very welcome!
--Florian

It looks to me like there is no easy way to do it. This is a deficiency in the way steps are implemented at present. The generation of the stepped path is buried in a Line2D helper method, and the path is not saved. If it were, its x and y coordinates could be passed to fill_between, which would then provide the effect you want.

Unless and until some refactoring is done in mpl, you will have to manually generate the x and y coordinates corresponding to your stepped line instead of using plt.step.

It may be too much of a change to make to the API now, but I think that the step-generation should not be done in Line2D at all; it should be at the next level up. The Line2D object should not be modifying the coordinates it is given. At the very least, its get_path() should return the actual path it is drawing; at present it does not. This latter change may be relatively easy.

Eric

···

**NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en su caso los ficheros adjuntos, pueden contener información protegida para el uso exclusivo de su destinatario. Se prohíbe la distribución, reproducción o cualquier otro tipo de transmisión por parte de otra persona que no sea el destinatario. Si usted recibe por error este correo, se ruega comunicarlo al remitente y borrar el mensaje recibido.
**CONFIDENTIALITY NOTICE** This email communication and any attachments may contain confidential and privileged information for the sole use of the designated recipient named above. Distribution, reproduction or any other use of this transmission by any party other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender and delete all copies.

------------------------------------------------------------------------

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users