plotting without using pylab

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

All of the examples in the "api" directory use the object-oriented interface, rather than the pylab one.

Florian Koelling 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

-------------------------------------------------------------------------
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
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

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

···

On Wed, Oct 1, 2008 at 12:34 PM, Florian Koelling <florian.koelling@…2064…> wrote:


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

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
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 > <florian.koelling@…2064… <mailto:florian.koelling@…2064…>> 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=/
    <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
    _______________________________________________
    Matplotlib-users mailing list
    Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------

-------------------------------------------------------------------------
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

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
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!
  

As I said before, look in the examples/api directory (available here http://matplotlib.sourceforge.net/matplotlib_examples_0.98.3.zip) for examples of using the non-pyplot API.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Florian Koelling wrote:

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

It sounds like you have a problem with whatever back-end is the default. Try changing that in your .matplotlibrc file, or try:

import matplotlib
matplotlib.use('Agg') # or 'wxagg', or 'whatever'

import pylab

that should do it.

What back end - are you/do you want to - use?

despite all the pylab examples, the OO inteface has a lot of advantages...

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

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 >> <florian.koelling@…2064… <mailto:florian.koelling@…2064…>> 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