views:

29

answers:

2

Hi,

I am trying to plot do a basic semilog plot using pyplot and matplotlib, with the y-axis being the logarithmic scale. I am using the following code:

pylab.figure(num=None,figsize=(8,6))  
pylab.plot(x_loc,var1,x_loc,var2)  
\#pylab.yscale('log')  
pylab.xlabel('$y/L_{1/2}$',fontsize=18)  
pylab.ylabel('$n/n_{max}$',fontsize=18)  
pylab.title('Particle Concentration vs. Position',fontsize=18)  
pylab.show() 

This gives me a fine linear plot with the third line commented as above, but when I uncomment this line and rerun, the data disappears from the plot. The plot window has the correct limits, but there is no data anymore.

Has anyone come across this problem before?

Thanks!
Peter

A: 

By using set_yscale('log') you can change that property of the yscale when an object has already been created. Give it a try and see if it fixes your problem. The docs for this are here: http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set%5Fyscale

also, try changing your render. do a:

from matplotlib import use
use('TkAgg')
import pylab

(only import pylab after the use command)

relima
Thanks for the quick response, but unfortunately that doesn't solve the problem. Neither does using pylab.semilogy. I notice that if I pan outside the region where the data should be and pan back in, the data reappears. But I would rather not have to do this every time...
Peter
which version of matplotlib are you using?
relima
A: 

It looks like it's a bug in the EPDLab package I am using (from Enthought). If I run this command from IPython or the terminal (python 'filename'), the plot is output correctly.

Peter