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

> Benjamin Root <ben.root-grryuj3d...@public.gmane.org <javascript:;>>
> writes:
> > 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?
> >
> > Correct, I think you want plt.draw().
>
> Thanks, that works! But why is it necessary? Does interactive mode only
> apply to direct pyplot.* commands?
>
>
> Thanks,
>
>    -Nikolaus


Not quite.  It is that the pyplot commands have a "draw_if_interactive"
call as a final step.  This way, matplotlib can defer drawing until it is
really needed.  This improves responsiveness.  When in OO mode, the
training wheels come off and the developer is responsible for issuing
draw() calls when they need to.

Cheers!
Ben Root
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to