From: Lorenzo I. <lor...@gm...> - 2007-07-06 10:49:18
|
Dear All, I am a bit puzzled at an unusual problem I am experiencing. Fundamentally, I call a couple of functions and I plot some data. First, I create a semilog plot using pylab.semilogx, then I make a normal linear plot. But, in the second case I get an error message: Traceback (most recent call last): File "./air-mean-free-path.py", line 206, in ? pylab.plot((diam_seq*1e9),K_bis,linewidth=2.) File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 2027, in plot ret = gca().plot(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 2131, in plot self.autoscale_view(scalex=scalex, scaley=scaley) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 985, in autoscale_view self.set_xlim(XL) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1220, in set_xlim raise ValueError('Cannot set nonpositive limits with log transform') ValueError: Cannot set nonpositive limits with log transform Which seems to be dealing with a semilog plot again, but that is no longer the case. What is going on? I am using the pylab.hold(False) command at the end of each plot in order not to mess everything up. Below there is the code producing the bug. If I go, after the 1st semilog plot, for another semilog plot, everything is fine and no error is generated. K_thermo=K_talbot_test(T,knudsen,Ra) pylab.semilogx(knudsen,K_thermo,linewidth=2.) pylab.xlabel('knudsen number',fontsize=20.) pylab.ylabel('K_th',fontsize=20.) pylab.title('Thermophoretic coefficient',fontsize=20.) pylab.grid(True) pylab.savefig('thermophoretic_coefficient') pylab.hold(False) diam_seq=pylab.load("diameter_sequence") diam_seq=diam_seq/1e9 print 'the shape of diam_seq is', shape(diam_seq) K_bis=K_talbot(T) print 'the shape of k_bis is', shape(K_bis) #pylab.semilogx((diam_seq*1e9),K_bis,linewidth=2.) pylab.plot((diam_seq*1e9),K_bis,linewidth=2.) # with the plot command I run into trouble, with semilogx everything is fine instead. pylab.xlabel('diameter [nm]',fontsize=20.) pylab.ylabel('K_th',fontsize=20.) #pylab.legend(('prey population','predator population')) pylab.title('Thermophoretic coefficient at T=350K',fontsize=20.) pylab.grid(True) pylab.savefig('thermophoretic_coefficient_vs_particle_diameter') pylab.hold(False) Does anybody have a clue at what is going on? I am sure it must be something quick to fix. Many thanks Lorenzo |