Oops, I replied to your previous message before seeing this
> one. Still, the larger question remains: maybe we should do
> something to make it easier for users to understand what is
> going on when the transform chokes on log(0). Changing
> numbers <=0 to a small positive number and issuing a warning
> would accomplish this, and I don't see much disadvantage.
This is tricky to implement in practice. Eg, what if the user did a
bar graph where the heights were order 1e-10? Without knowing what
the user intended when creating the graphics primitives it is
difficult to know what to do with them. I am hesitant to alter data
at the level of graphics primitives without knowing the operation that
created them. One possible solution may be to simply create a
helper function (loghist, logbar) which works like semilogx: it knows
what the user wants to do and does the right thing, in this case
making sure that the "bottom" of the rectangles is some suitable
positive number less than all the heights.
I definitely agree that the error message is not terribly helpful.
One possibility is to inspect most of the objects at set_xscale and
set_yscale and issue a warning if there is non-positive data.
Eg: 'one or more patches has a non-positive y coordinate'
This won't be too helpful for mpl newbies who don't know what a patch
is, but it will provide some additional information (at the expense of
inspecting all the data at scale changes)
Something like
if xscale=='log':
for line in self.lines:
xdata = line.get_xdata(valid_only = True)
if min(xdata)<=0.:
warn on lines and break
for patch in self.patches:
if min([x for x,y in patch.get_verts()])<=0.:
warn on patches and break
for collection in self.collections:
if min([x for x,y in collection.get_verts()])<=0.:
warn on collections and break
JDH