Re: [Matplotlib-users] Different between canvas.draw() and canvas.restore_region()??

2008-04-20 Thread hjc520070

Thanks for your help. I get it work. However, an interesting thing appears.
The following two codes(code 1 and code 2) makes different result??? Only
set background in different place. Anyone can tell me why? I am eager to
know it.

##code 1
import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure

class Temp: 
def __init__(self):

self.step=0

app = wx.PySimpleApp()
frame=wx.Frame(None,size=(700,500))
frame.Show(True)

##Creat figure , canvas , axe.
fig = Figure((8.8,6),facecolor='w')
self.canvas = FigureCanvasWxAgg(frame, -1, fig)
self.ax=fig.add_axes([0.1,0.15,0.7,0.7],axisbg='#dedff7')

##Create line on axe.
self.y=[1,1]
self.x=[0,10]
self.line,=self.ax.plot(self.x,self.y,animated=True)

##Bind timer to refresh line
timer=wx.Timer()
timer.Bind(wx.EVT_TIMER, self.OnTimer, timer)
timer.Start(1000)  

app.MainLoop()
 
def OnTimer(self,event):

self.step=self.step+1
   
if self.step==1:
self.background=self.canvas.copy_from_bbox(self.ax.bbox)

self.y=[self.y[0]+0.005,self.y[1]+0.005]
self.canvas.restore_region(self.background)   
self.line.set_data(self.x,self.y)
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
Temp()


##Code 2
import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure

class Temp:

def __init__(self):

self.step=0

app = wx.PySimpleApp()
frame=wx.Frame(None,size=(700,500))
frame.Show(True)

##Creat figure , canvas , axe.
fig = Figure((8.8,6),facecolor='w')
self.canvas = FigureCanvasWxAgg(frame, -1, fig)
self.ax=fig.add_axes([0.1,0.15,0.7,0.7],axisbg='#dedff7')

##Create line on axe.
self.y=[1,1]
self.x=[0,10]
self.line,=self.ax.plot(self.x,self.y,animated=True)

self.background=self.canvas.copy_from_bbox(self.ax.bbox)

##Bind timer to refresh line
timer=wx.Timer()
timer.Bind(wx.EVT_TIMER, self.OnTimer, timer)
timer.Start(1000)  

app.MainLoop()
 
def OnTimer(self,event):

self.step=self.step+1
   
self.y=[self.y[0]+0.005,self.y[1]+0.005]
self.canvas.restore_region(self.background)   
self.line.set_data(self.x,self.y)
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
Temp()   




-- 
View this message in context: 
http://www.nabble.com/Different-between-canvas.draw%28%29-and-canvas.restore_region%28%29---tp16790656p16801603.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Compiler error on OS X 10.5.2 in agg

2008-04-20 Thread Eric Firing
John Hunter wrote:
> On Mon, Mar 24, 2008 at 2:48 PM, Charlie Moad <[EMAIL PROTECTED]> wrote:
>> This is a compiler problem the with the gcc on 10.5.2 (and 10.5.1
>> I think).  I found the same error message on many google hits outside of
>> matplotlib.  Your suggestion of compiling with -Os for the two problem files
>> worked fine for me.
> 
> 
> What is the best way to set this flag?  Can it be done with an
> environment variable or by editing a config file?


http://docs.python.org/inst/tweak-flags.html#SECTION00061

Have you tried the methods above? (I have not.) They would apply to the 
whole build, but for mpl I don't see that as a problem, provided they 
make the build work.

Eric

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Compiler error on OS X 10.5.2 in agg

2008-04-20 Thread John Hunter
On Mon, Mar 24, 2008 at 2:48 PM, Charlie Moad <[EMAIL PROTECTED]> wrote:
> This is a compiler problem the with the gcc on 10.5.2 (and 10.5.1
> I think).  I found the same error message on many google hits outside of
> matplotlib.  Your suggestion of compiling with -Os for the two problem files
> worked fine for me.


What is the best way to set this flag?  Can it be done with an
environment variable or by editing a config file?

JDH

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Different between canvas.draw() and canvas.restore_region()??

2008-04-20 Thread John Hunter
On Sun, Apr 20, 2008 at 3:33 AM, hjc520070 <[EMAIL PROTECTED]> wrote:
>
> canvas.draw() is slow in animation, I have succeed in replacing it with
>  canvas.restore_region(). And it is wonderful.
> However, in the following, I fail to make it work the same as
>  canvas.draw().The following code can work. And creat a dynamic line. When I
>  work with the statement "#self.canvas.draw()" .The result is exactly what I
>  want.
>
>  However, canvas.restore_region() fail to do as canvas.draw() here. The
>  problem is when I refresh the line, the previous line is not clear as I want
>  to.Could anyone help me? Thanks.

The basic idiom is show in the attached example animation_blit.py.
You create a line with the "amimated" property set True.  Then calling
draw will draw everything but the animated objects

line, = p.plot(x, npy.sin(x), animated=True, lw=2)


Then you copy the drawn region minus the animated parts as a
background.  On the first draw, do

.background = canvas.copy_from_bbox(ax.bbox)

Then to animate your line, restore the background, update your line
data, and blit the region:

canvas.restore_region(background)
line.set_ydata(ydata)
ax.draw_artist(line)
canvas.blit(ax.bbox)

There are animation blit examples for most GUI toolkits in the
examples directory.

JDH


animation_blit.py
Description: Binary data
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [n00b] removing y axis and keeping x

2008-04-20 Thread Daniel Fetchinson
On 4/19/08, Eric Firing <[EMAIL PROTECTED]> wrote:
> Daniel Fetchinson wrote:
> [...]
> > Yes, this would be really useful. For the moment I'll just turn off
> > all axis, I managed to do that. By the way is it possible to just turn
> > off the axis and not the tick labels?
>
> In your example below you could try
> graph.set_frame_on(False)
> That will leave the ticks and the tick labels but remove the box and
> the axes background, leaving the figure background (which you can set if
> needed).  If you also want to knock out the ticks, you can do this:
>
> tl = graph.xaxis.get_ticklines()
> for t in tl:
>  t.set_visible(False)
>
> and similarly for yaxis.
>
> [...]
> > Maybe I'm misunderstanding something but this doesn't really work as
> > intended. I have this:
> >
> > figure = pylab.figure( )
> > figure.add_axes( [0,0,1,1] )  # this I added following your advice
> > graph = figure.add_subplot(111)
>
> Replace the last two lines above with the single line:
>graph = figure.add_axes( [0,0,1,1] )
> and the rest should work.
>
> Eric
>

Great, thanks very much!

Cheers,
Daniel

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Different between canvas.draw() and canvas.restore_region()??

2008-04-20 Thread hjc520070

canvas.draw() is slow in animation, I have succeed in replacing it with
canvas.restore_region(). And it is wonderful.
However, in the following, I fail to make it work the same as
canvas.draw().The following code can work. And creat a dynamic line. When I
work with the statement "#self.canvas.draw()" .The result is exactly what I
want.

However, canvas.restore_region() fail to do as canvas.draw() here. The
problem is when I refresh the line, the previous line is not clear as I want
to.Could anyone help me? Thanks. 


import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure

class Temp:

def __init__(self):
app = wx.PySimpleApp()
frame=wx.Frame(None,size=(700,500))
frame.Show(True)

##Creat figure , canvas , axe.
fig = Figure((8.8,6),facecolor='w')
self.canvas = FigureCanvasWxAgg(frame, -1, fig)
self.ax=fig.add_axes([0.1,0.15,0.7,0.7],axisbg='#dedff7')

##Get background for OnTimer function.
self.background=self.canvas.copy_from_bbox(self.ax.bbox)

##Create line on axe.
self.y=[1,1]
self.x=[0,10]
self.line,=self.ax.plot(self.x,self.y)

##Bind timer to refresh line
timer=wx.Timer()
timer.Bind(wx.EVT_TIMER, self.OnTimer, timer)
timer.Start(1000)
app.MainLoop()

def OnTimer(self,event):

self.y=[self.y[0]+0.005,self.y[1]+0.005]
  
self.line.set_data(self.x,self.y)
self.canvas.restore_region(self.background) 
 
self.ax.draw_artist(self.line)
self.canvas.blit(self.ax.bbox)
self.canvas.gui_repaint()
#self.canvas.draw()
Temp()   

-- 
View this message in context: 
http://www.nabble.com/Different-between-canvas.draw%28%29-and-canvas.restore_region%28%29---tp16790656p16790656.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users