Re: [Matplotlib-users] Error when plotting negative values on log scale
Thanks for info Goyo and Ben! 2011/3/11 Benjamin Root > > > 2011/3/10 Søren Nielsen > >> Hi, >> >> >> When I do an errorbar plot (a.errorbar(), a = axis) with negative values >> and then try to change the yscale to log (a.set_yscale('log')) matplotlib >> crashes with: >> >> Traceback (most recent call last): >> File >> "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line >> 14636, in >> lambda event: event.callable(*event.args, **event.kw) ) >> File "/home/specuser/new_workspace/TestDriven/src/RAWPlot.py", line 371, >> in plotSASM >> line, ec, el = a.errorbar(sasm.q[q_min:q_max], sasm.i[q_min:q_max], >> sasm.err[q_min:q_max], picker = 3, label = legend_label, **kwargs) >> File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 4872, >> in errorbar >> barcols.append( self.vlines(x, lower, upper, **lines_kw) ) >> File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 3302, >> in vlines >> self.autoscale_view() >> File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 1627, >> in autoscale_view >> YL = self.yaxis.get_major_locator().view_limits(y0, y1) >> File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line >> 1119, in view_limits >> if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base) >> File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line >> 1030, in is_decade >> return lx==int(lx) >> OverflowError: cannot convert float infinity to integer >> Traceback (most recent call last): >> File >> "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line >> 14636, in >> lambda event: event.callable(*event.args, **event.kw) ) >> File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 1953, in >> addItem >> newItem = ManipItemPanel(self.underpanel, sasm, font_colour = >> item_colour) >> File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 2353, in >> __init__ >> color = conv.to_rgb(self.sasm.line.get_mfc()) >> AttributeError: 'NoneType' object has no attribute 'get_mfc' >> >> I don't think this should be the expected outcome.. rather it should not >> plot values that are illegal/negative (i.e. ignore them). >> >> Is there a way I can get around this without having to search through my >> data and remove points that are negative or NaN or INF when the yscale needs >> to be log? That would also show an incorrect curve since a line would be >> drawn across the points that were removed.. It should rather be gaps in the >> line. >> >> Thanks, >> Soren >> >> >> >> > Soren, > > This is a bug I encountered recently in my investigations with log scales. > While most projections are handling this properly, there are some cases > where this problem sneaks in. I have not been able to figure out how to > permanently address this issue. > > For reference, the similiar issue is when zooming in on polar plots with > the radial axis in log scale. > > Ben Root > > -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error when plotting negative values on log scale
2011/3/10 Søren Nielsen > Hi, > > When I do an errorbar plot (a.errorbar(), a = axis) with negative values > and then try to change the yscale to log (a.set_yscale('log')) matplotlib > crashes with: > > Traceback (most recent call last): > File > "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line > 14636, in > lambda event: event.callable(*event.args, **event.kw) ) > File "/home/specuser/new_workspace/TestDriven/src/RAWPlot.py", line 371, > in plotSASM > line, ec, el = a.errorbar(sasm.q[q_min:q_max], sasm.i[q_min:q_max], > sasm.err[q_min:q_max], picker = 3, label = legend_label, **kwargs) > File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 4872, > in errorbar > barcols.append( self.vlines(x, lower, upper, **lines_kw) ) > File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 3302, > in vlines > self.autoscale_view() > File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 1627, > in autoscale_view > YL = self.yaxis.get_major_locator().view_limits(y0, y1) > File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line > 1119, in view_limits > if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base) > File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line > 1030, in is_decade > return lx==int(lx) > OverflowError: cannot convert float infinity to integer > Traceback (most recent call last): > File > "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line > 14636, in > lambda event: event.callable(*event.args, **event.kw) ) > File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 1953, in > addItem > newItem = ManipItemPanel(self.underpanel, sasm, font_colour = > item_colour) > File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 2353, in > __init__ > color = conv.to_rgb(self.sasm.line.get_mfc()) > AttributeError: 'NoneType' object has no attribute 'get_mfc' > > I don't think this should be the expected outcome.. rather it should not > plot values that are illegal/negative (i.e. ignore them). > > Is there a way I can get around this without having to search through my > data and remove points that are negative or NaN or INF when the yscale needs > to be log? That would also show an incorrect curve since a line would be > drawn across the points that were removed.. It should rather be gaps in the > line. > > Thanks, > Soren > > > > Soren, This is a bug I encountered recently in my investigations with log scales. While most projections are handling this properly, there are some cases where this problem sneaks in. I have not been able to figure out how to permanently address this issue. For reference, the similiar issue is when zooming in on polar plots with the radial axis in log scale. Ben Root -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error when plotting negative values on log scale
2011/3/10 Søren Nielsen : > Is there a way I can get around this without having to search through my > data and remove points that are negative or NaN or INF when the yscale needs > to be log? That would also show an incorrect curve since a line would be > drawn across the points that were removed.. It should rather be gaps in the > line. You can use masked arrays. Masked values don't get plotted. Sample code (not tested): import numpy.ma as ma # masked arrays module ... mdata = ma.masked_array(data) mdata[mdata <= 0] = ma.masked plot(mdata) Goyo -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Error when plotting negative values on log scale
Hi, When I do an errorbar plot (a.errorbar(), a = axis) with negative values and then try to change the yscale to log (a.set_yscale('log')) matplotlib crashes with: Traceback (most recent call last): File "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14636, in lambda event: event.callable(*event.args, **event.kw) ) File "/home/specuser/new_workspace/TestDriven/src/RAWPlot.py", line 371, in plotSASM line, ec, el = a.errorbar(sasm.q[q_min:q_max], sasm.i[q_min:q_max], sasm.err[q_min:q_max], picker = 3, label = legend_label, **kwargs) File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 4872, in errorbar barcols.append( self.vlines(x, lower, upper, **lines_kw) ) File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 3302, in vlines self.autoscale_view() File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 1627, in autoscale_view YL = self.yaxis.get_major_locator().view_limits(y0, y1) File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line 1119, in view_limits if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base) File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line 1030, in is_decade return lx==int(lx) OverflowError: cannot convert float infinity to integer Traceback (most recent call last): File "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14636, in lambda event: event.callable(*event.args, **event.kw) ) File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 1953, in addItem newItem = ManipItemPanel(self.underpanel, sasm, font_colour = item_colour) File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 2353, in __init__ color = conv.to_rgb(self.sasm.line.get_mfc()) AttributeError: 'NoneType' object has no attribute 'get_mfc' I don't think this should be the expected outcome.. rather it should not plot values that are illegal/negative (i.e. ignore them). Is there a way I can get around this without having to search through my data and remove points that are negative or NaN or INF when the yscale needs to be log? That would also show an incorrect curve since a line would be drawn across the points that were removed.. It should rather be gaps in the line. Thanks, Soren -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users