Axes.stem() doesn't draw stemlines if yscale is logarithmic

Hello,

I tried to do a stem plot on an Axes with logarithmic scale, experiencing that the stemlines were not drawn...

====axes.py (svn trunk, 2008-07-08):
def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-'):
[...]
    stemlines = []
    for thisx, thisy in zip(x, y):
        l, = self.plot([thisx,thisx], [0, thisy], linefmt)
        stemlines.append(l)

After Axes.set_yscale('log'), Axes.stem() no longer draws the stemlines because it tries to draw from y=0, thereby apparently triggering some guard which prevents plotting log(0), hence suppressing the complete stemline.

Dirty hacking, I replace [0, thisy] with [1, thisy] in case yscale=='log' and it works for my plots, but for sure there is more to do to make it robust...

Please give me a heads-up if I just oversaw the Right Way to do a stem plot with logarithmic yscale.

Cheers,
Dirk

This is a tricky one. It appears this bug also exists in 0.91.x, perhaps earlier as well, so it isn't a regression.

I don't like the idea of setting the minimum to "1", especially for when the scale isn't log. Setting it to a really small positive value (like 1e-9) is better, but the autoscaling of the log plot then goes down to 1e-9 as well.

Do any other developers have better suggestions? We may have to do some magic in at drawing time (or convince the autoscaler to ignore the stem lines) -- but I'd like to find a way that minimizes additional complexity.

Cheers,
Mike

···

Dirk.Juelich@...2093... wrote:

Hello,

I tried to do a stem plot on an Axes with logarithmic scale, experiencing that the stemlines were not drawn...

====axes.py (svn trunk, 2008-07-08):
def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-'):
[...]
    stemlines = []
    for thisx, thisy in zip(x, y):
        l, = self.plot([thisx,thisx], [0, thisy], linefmt)
        stemlines.append(l)

After Axes.set_yscale('log'), Axes.stem() no longer draws the stemlines because it tries to draw from y=0, thereby apparently triggering some guard which prevents plotting log(0), hence suppressing the complete stemline.

Dirty hacking, I replace [0, thisy] with [1, thisy] in case yscale=='log' and it works for my plots, but for sure there is more to do to make it robust...

Please give me a heads-up if I just oversaw the Right Way to do a stem plot with logarithmic yscale.

Cheers,
Dirk

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Is it possible do proceed as using axvline, i.e. specifying the axes
coordinates? In this case, it would require a mix of data coordinate
(the value to display) and of axes coordinate (the bottom of the curve).

When would values to render be converted ?

···

Le lundi 14 juillet 2008 à 09:08 -0400, Michael Droettboom a écrit :

Do any other developers have better suggestions? We may have to do some
magic in at drawing time (or convince the autoscaler to ignore the stem
lines) -- but I'd like to find a way that minimizes additional complexity.

--
Fabrice Silva <silva@...1918...>
LMA UPR CNRS 7051 - équipe S2M