Hi Michael,

I use fill_between() and log axis without problems in the following way (it's by memory, I hope the sintax is correct)

fig = plt.figure()

spl = fig.add_subplot(111)spl.fill_between(x,y1,y2)

spl.set_yscale("log")

plt.show()

Cheers,

Fra

>

>

> A colleague posed an interesting challenge:

> How to do a filled plot having the y-axis in logarithm?

> I think I can do it with creating patches myself an adding it to the

> axis, but isn't there anything built-in?

>

> Best regards,

> Michael

>

>

>

> Does fill_between() not work for you? Note, I have never tried it on a log scale plot.

>

> Ben Root

>

Another couple things you may find useful as I did:

fig = pyplot.figure()

spl = fig.add_subplot(111)

to properly "clip" the plot in case you are using polygons or similar,

you can use the nonposy option:

spl.set_yscale('log', nonposy='clip')

Here is my hand made formula for setting reasonable limits on the

y-axis, given a numpy.array "yarr" as the list of y-values. The ymin

gets the minimum value that's not zero since you can't plot zero on a

log scale (negative numbers may cause a whole other problem):

spl.set_ylim(

ymin = 10**(int(math.log(min(yarr[numpy.where(yarr>0)]), 10))-1),

ymax = 10**(int(math.log(max(yarr), 10)+0.2)+1) )

--Johann

## ···

Il giorno 06/mag/2011, alle ore 01.34, Benjamin Root ha scritto:

> On Tue, May 3, 2011 at 3:40 AM, K.-Michael Aye <kmichael.aye@...287...> wrote: