John Hunter wrote:
>>>>>> "Diwaker" == Diwaker Gupta <[EMAIL PROTECTED]> writes:
> 
>     >> >> The following minimal script reveals a rendering problem
>     >> with >> displaying a histogram on a log vertical axis.
> 
>     Diwaker> Has this been resolved yet? I'm running Matplotlib
>     Diwaker> 0.87.5-2.2 on Debian Unstable. I try to run the following
>     Diwaker> script:
> 
>     Diwaker> from pylab import * hist(rand(100), 20) ax = gca()
>     Diwaker> ax.set_yscale('log') show()
> 
> You have to make sure your yaxis limits are strictly positive, eg
> 
>   ax.set_ylim(1e-3, 1e3)
>   ax.set_yscale('log')


This doesn't work.  The problem is that the patch objects are made 
first, and they start at y=0, so changing the y limits doesn't prevent 
the attempt to take the log of zero.

One solution would be to have the transform simply trap zero and 
negative inputs and change them, with or without a warning, to some very 
small positive value.  This would do the right thing in the present 
case.  In cases where a zero is used inadvertently and incorrectly, and 
where an exception really should be raised, it would not do so.  Maybe 
this is a worthwhile tradeoff?  This question has come up quite a few 
times, and it would be nice to stop that.

A solution for hist would be a kwarg to handle the log case.  If hist is 
the only context in which this problem arises--that is, if all other 
cases are ones in which the zero has no business being there so an 
exception is appropriate--then adding log-handling to hist would be the 
way to go.  But I suspect there are other cases, and we will keep 
getting this question.  It's understandable, because the exception that 
gets triggered is not very informative.

Eric

> 
> 
> JDH

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to