Using object oriented interface in interactive mode?

Hello,

The following code shows the plot right away as expected:

# python
Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib
matplotlib.__version__

'1.1.1rc2'

import matplotlib.pyplot as plt
plt.interactive(True)
plt.plot(range(10))

[<matplotlib.lines.Line2D object at 0x2ce7790>]

This, however, opens a window but the graph never shows up:

# python
Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib.pyplot as plt
plt.interactive(True)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(range(10))

[<matplotlib.lines.Line2D object at 0x3055d90>]

Does interactive mode only apply to the plot commands in pyplot?

Is there a method I can call in this case to "refresh" the window and
show the plot?

For seem reason, calling plt.axes() has the desired effect, but this is
probably a side effect that I really should not rely on, right?

Thanks!

   -Nikolaus

···

--
»Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C

Correct, I think you want plt.draw().

Cheers!
Ben Root

···

On Sunday, August 5, 2012, Nikolaus Rath wrote:

Hello,

The following code shows the plot right away as expected:

python

Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17)

[GCC 4.6.3] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib

matplotlib.version

‘1.1.1rc2’

import matplotlib.pyplot as plt

plt.interactive(True)

plt.plot(range(10))

[<matplotlib.lines.Line2D object at 0x2ce7790>]

This, however, opens a window but the graph never shows up:

python

Python 2.7.3rc2 (default, Apr 22 2012, 22:30:17)

[GCC 4.6.3] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib.pyplot as plt

plt.interactive(True)

fig = plt.figure()

ax = fig.add_subplot(1,1,1)

ax.plot(range(10))

[<matplotlib.lines.Line2D object at 0x3055d90>]

Does interactive mode only apply to the plot commands in pyplot?

Is there a method I can call in this case to “refresh” the window and

show the plot?

For seem reason, calling plt.axes() has the desired effect, but this is

probably a side effect that I really should not rely on, right?

Thanks!

-Nikolaus