Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
I think this is happening because I am plotting a gaussian that is very narrow compared to the x range. Still it seems failing here is bad behavior.
here is some code that reproduces the problem, taken from IPython notebook:
%matplotlibinlineimportmatplotlib.pyplotaspltfromscipy.statsimportnormasscipy_stats_normfrommathimportsqrtplt.clf()fig,ax=plt.subplots()max_x=1100# this fails#max_x = 1000 # this worksx=np.linspace(-max_x,max_x,300)mean=-0.0938stdev=sqrt(0.008812)ax.plot(x,scipy_stats_norm.pdf(x,loc=mean,scale=stdev),color='red',linewidth=2)ax.set_yticklabels([])ax.set_xlim(-max_x,max_x)filename='/tmp/fail.png'plt.savefig(filename,bbox_inches='tight')plt.show()
Here's the result:
File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/pyplot.py",line561,insavefigreturnfig.savefig(*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/figure.py",line1421,insavefigself.canvas.print_figure(*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backend_bases.py",line2167,inprint_figure**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py",line505,inprint_pngFigureCanvasAgg.draw(self)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py",line451,indrawself.figure.draw(self.renderer)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py",line55,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/figure.py",line1034,indrawfunc(*args)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py",line55,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/axes.py",line2086,indrawa.draw(renderer)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py",line55,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/axis.py",line1096,indrawtick.draw(renderer)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py",line55,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/axis.py",line241,indrawself.label1.draw(renderer)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/artist.py",line55,indraw_wrapperdraw(artist,renderer,*args,**kwargs)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/text.py",line598,indrawismath=ismath,mtext=self)File"/opt/datasci-python/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py",line188,indraw_textfont.get_image(),np.round(x-xd),np.round(y+yd)+1,angle,gc)ValueError:cannotconvertfloatNaNtointeger