SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Mike K. <mc...@gm...> - 2011年05月22日 17:04:37
Hi,
After switching over from the MacOSX backend to the GTKAgg backend, I 
started notice a big change in drawing behavior.
Now I know that MacOSX is interactive all the time by [mis]design, so I 
wasn't surprised that I would have to add draw() commands when 
isinteractive()==False; however, when using the non-pyplot commands, 
i.e. ax.plot() rather than plot(), I must use draw() to render the new 
Line2D even when isinteractive()==True. This doesn't seem correct 
behavior to me. A lot of drawing just can't be done by the pyplot 
functions. You have to go to the axes functions.
On another, but related topic, I use ipython -pylab, and generally 
develop by using the `run -i file.py` syntax. I have found what I think 
is a bug where if I have a file that consists of:
cat >> file.py <<EOF
print isinteractive()
EOF
and I do
In [1]: isinteractive()
Out[1]: True
In [2]: run -i file.py
False
which means I either have to do ion() or draw() each time even for 
pyplot commands. Is this a bug in ipython or matplotlib?
M
From: Eric F. <ef...@ha...> - 2011年05月22日 20:15:19
On 05/22/2011 07:04 AM, Mike Kaufman wrote:
> Hi,
>
> After switching over from the MacOSX backend to the GTKAgg backend, I
> started notice a big change in drawing behavior.
>
> Now I know that MacOSX is interactive all the time by [mis]design, so I
> wasn't surprised that I would have to add draw() commands when
> isinteractive()==False; however, when using the non-pyplot commands,
> i.e. ax.plot() rather than plot(), I must use draw() to render the new
> Line2D even when isinteractive()==True. This doesn't seem correct
> behavior to me. A lot of drawing just can't be done by the pyplot
> functions. You have to go to the axes functions.
This is inherent in the design. Pyplot functions are wrappers that do 
two things: call Axes methods on the current axes, and then call 
draw_if_interactive(). The rationale is that even when working 
interactively, one doesn't necessarily want to draw immediately every 
time a new Artist is created. So yes, working interactively with the OO 
interface requires frequent plt.draw() invocations, making it only 
semi-interactive.
>
> On another, but related topic, I use ipython -pylab, and generally
> develop by using the `run -i file.py` syntax. I have found what I think
> is a bug where if I have a file that consists of:
>
> cat>> file.py<<EOF
> print isinteractive()
> EOF
>
> and I do
>
> In [1]: isinteractive()
> Out[1]: True
> In [2]: run -i file.py
> False
>
> which means I either have to do ion() or draw() each time even for
> pyplot commands. Is this a bug in ipython or matplotlib?
I think it is inherent in the -pylab mode of ipython, which is designed 
to run a script as if it were being run directly from the command line. 
To do that, it turns interactive mode off before running the script, and 
restores interactive mode to its original value afterwards. A script 
intended to produce a screen plot includes a show() command. Running 
such a script with ipython -pylab then leaves one or more plots with 
which one can interact directly or via the ipython command line--but in 
the latter case, if pyplot functions are not used, then draw() must be 
used for a redraw.
If you want the contents of the file to be executed exactly as if you 
had typed them in at the ipython command line, you can use the built-in 
execfile() function instead of the ipython %run magic.
The ipython %edit magic can also be used for this.
Eric
>
> M
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /