Florian Koelling wrote:
> Hello again!
> 
> I think it's not a namespace problem.
> I tried:
> 
> from pylab import plot as pplot
> import pylab as p
> 
> As result I received busted SD Files. I ' ve this problem nearly for

I am not familiar with pybel and I don't know what an SD file is, so I 
have no idea what you mean above.  It would be nice to know where the 
interference is coming from, even if you can work around it by using the 
  OO api or some other suggestion.

First, for plotting capability, don't use pylab, use pyplot:

import matplotlib.pyplot as plt
plt.plot(...)
or
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(...)
plt.show()

Many of the examples have been converted to use this recommended idiom.

Pyplot has the plotting part of pylab without dumping numpy into the 
namespace.  I suspect, however, that in your case the result of 
importing matplotlib.pyplot will be the same

Second, do you need plots on the screen, or is it enough to generate 
plot files?  If the latter, see the agg_oo.py example of how to 
eliminate pylab/pyplot completely (watch out for spurious line breaks in 
the following paste-in):

from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_title('hi mom')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
canvas.print_figure('test')

This makes png files. If you want ps or pdf, the method would be the 
same but with the appropriate backend.

Eric

> three months - so I switched to Gnuplot - now recognizing that it is
> doesn't  have
> enough performance to make a large amount of plots.
> 
> (I tried local imports in a function as well -- same result)
> 
> Actually I'm not using any matplotlib code -- just the import statement
> -- and it's enough that all goes to hell.
> 
> With "import matplotlib" I do not have  those  problems - most plotting
> examples are dealing with pylab -- what can I use instead?
> 
> Maybe one of you Harry Plotters  has  an idea!
> 
> Thanks,
> 
> Florian
> 
> 
> Gary Pajer wrote:
>> On Wed, Oct 1, 2008 at 12:34 PM, Florian Koelling
>> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>>
>>     Hi Folks!
>>
>>     Is there a way to plot simple x/y Data in matplotlib WITHOUT using the
>>     "import pylab" command? (in all examples I only saw pylab).
>>
>>     I' working with openbabel(pybel) as well and I've got serious problems
>>     whenever I use "from pylab import plot" or similar commands -
>>
>>     (if I do, SDF files aren't read out anymore properly...)
>>
>>
>>     Thanks alot
>>
>>
>> If the problem is "namespace pollution"  (one package overriding names
>> defined earlier) then the following should work:
>>
>> from pylab import plot as pplot  (where "pplot" is an unused name)
>>
>> or
>>
>> import pylab as p
>>
>> then use, p.plot() instead of plot()
>> (this latter method is what I use.)
>>
>> hth,
>> gary

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to