Re: [matplotlib-devel] Help with blitting bug with subplots and markers

2010-07-06 Thread Michael Droettboom
On 07/04/2010 09:32 PM, John Hunter wrote:
 On Sat, Jul 3, 2010 at 11:53 AM, Ryan Mayrma...@gmail.com  wrote:

 On Sat, Jul 3, 2010 at 1:11 AM, Ryan Mayrma...@gmail.com  wrote:
  
 Alright, before I go to bed, I found the following line in
 src/_backend_agg.cpp at line 709 (in draw_markers()) makes all the
 difference:

 set_clipbox(gc.cliprect, rendererBase);

 Commenting out this line fixes my problem. I'm not sure why it's a
 problem, (maybe a missing restore to previous state somewhere?). I'll
 look into this tomorrow, but it would probably be a lot easier with
 someone familiar with the code.

 Following up again, it seems like the problem is that draw_marker is
 calling set_clipbox() on the rendererBase instead of theRasterizer,
 which is done at 7 other places in the code (as opposed to only one
 other location for rendererBase).  Since rendererBase is used for
 restore_region, this makes sense as to why it would fix my problem. I
 can confirm making the change fixes my problem and doesn't cause any
 other issues in my (admittedly brief so far) testing.

 (If this isn't the proper fix, an alternative is to call
 rendererBase.reset_clipping(true), but I really think this is working
 around the issue).

 Can someone more familiar with the agg backend weigh in here? I'm
 pretty comfortable with the fix, but don't want to be responsible for
 breaking pretty much all of matplotlib.
  
 Does marker clipping still work with the proposed change?

Unfortunately, not.

Ryan's suggestion to call rendererBase.reset_clipping(true) upon exit of 
draw_markers does seem to work both for the blitting and clipping, 
however.  I don't think this is working around the issue -- I think it's 
probably the correct solution.  The clipping state really should 
probably be reset around every backend call -- but this is the first 
instance we've seen where the stickiness is a problem, so I think I'll 
only fix it here (and not reset all the clipping calls to theRasterizer).

I've committed this change to 8515.

Mike
 The only thing that is special about marker drawing is we use cached
 marker rasters to make drawing many of them efficient, but I don't
 recall anymore whether this required special clipping treatment.

 JDH

 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 ___
 Matplotlib-devel mailing list
 Matplotlib-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-devel



-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA


--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Help with blitting bug with subplots and markers

2010-07-06 Thread Ryan May
On Tue, Jul 6, 2010 at 10:19 AM, Michael Droettboom md...@stsci.edu wrote:
 On 07/04/2010 09:32 PM, John Hunter wrote:
 On Sat, Jul 3, 2010 at 11:53 AM, Ryan Mayrma...@gmail.com  wrote:

 On Sat, Jul 3, 2010 at 1:11 AM, Ryan Mayrma...@gmail.com  wrote:

 Alright, before I go to bed, I found the following line in
 src/_backend_agg.cpp at line 709 (in draw_markers()) makes all the
 difference:

 set_clipbox(gc.cliprect, rendererBase);

 Commenting out this line fixes my problem. I'm not sure why it's a
 problem, (maybe a missing restore to previous state somewhere?). I'll
 look into this tomorrow, but it would probably be a lot easier with
 someone familiar with the code.

 Following up again, it seems like the problem is that draw_marker is
 calling set_clipbox() on the rendererBase instead of theRasterizer,
 which is done at 7 other places in the code (as opposed to only one
 other location for rendererBase).  Since rendererBase is used for
 restore_region, this makes sense as to why it would fix my problem. I
 can confirm making the change fixes my problem and doesn't cause any
 other issues in my (admittedly brief so far) testing.

 (If this isn't the proper fix, an alternative is to call
 rendererBase.reset_clipping(true), but I really think this is working
 around the issue).

 Can someone more familiar with the agg backend weigh in here? I'm
 pretty comfortable with the fix, but don't want to be responsible for
 breaking pretty much all of matplotlib.

 Does marker clipping still work with the proposed change?

 Unfortunately, not.

 Ryan's suggestion to call rendererBase.reset_clipping(true) upon exit of
 draw_markers does seem to work both for the blitting and clipping,
 however.  I don't think this is working around the issue -- I think it's
 probably the correct solution.  The clipping state really should
 probably be reset around every backend call -- but this is the first
 instance we've seen where the stickiness is a problem, so I think I'll
 only fix it here (and not reset all the clipping calls to theRasterizer).

 I've committed this change to 8515.

 Mike

Did this make it into 1.0.0? I didn't see it in the merges you did
earlier? If not, can we get it into the stable branch for the next
bugfix release? I'd love to only require the latest release (and not
trunk) when I finally put out my animation stuff for wider testing.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Help with blitting bug with subplots and markers

2010-07-04 Thread John Hunter
On Sat, Jul 3, 2010 at 11:53 AM, Ryan May rma...@gmail.com wrote:
 On Sat, Jul 3, 2010 at 1:11 AM, Ryan May rma...@gmail.com wrote:
 Alright, before I go to bed, I found the following line in
 src/_backend_agg.cpp at line 709 (in draw_markers()) makes all the
 difference:

 set_clipbox(gc.cliprect, rendererBase);

 Commenting out this line fixes my problem. I'm not sure why it's a
 problem, (maybe a missing restore to previous state somewhere?). I'll
 look into this tomorrow, but it would probably be a lot easier with
 someone familiar with the code.

 Following up again, it seems like the problem is that draw_marker is
 calling set_clipbox() on the rendererBase instead of theRasterizer,
 which is done at 7 other places in the code (as opposed to only one
 other location for rendererBase).  Since rendererBase is used for
 restore_region, this makes sense as to why it would fix my problem. I
 can confirm making the change fixes my problem and doesn't cause any
 other issues in my (admittedly brief so far) testing.

 (If this isn't the proper fix, an alternative is to call
 rendererBase.reset_clipping(true), but I really think this is working
 around the issue).

 Can someone more familiar with the agg backend weigh in here? I'm
 pretty comfortable with the fix, but don't want to be responsible for
 breaking pretty much all of matplotlib.

Does marker clipping still work with the proposed change?

The only thing that is special about marker drawing is we use cached
marker rasters to make drawing many of them efficient, but I don't
recall anymore whether this required special clipping treatment.

JDH

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Help with blitting bug with subplots and markers

2010-07-03 Thread Ryan May
On Sat, Jul 3, 2010 at 1:11 AM, Ryan May rma...@gmail.com wrote:
 Alright, before I go to bed, I found the following line in
 src/_backend_agg.cpp at line 709 (in draw_markers()) makes all the
 difference:

 set_clipbox(gc.cliprect, rendererBase);

 Commenting out this line fixes my problem. I'm not sure why it's a
 problem, (maybe a missing restore to previous state somewhere?). I'll
 look into this tomorrow, but it would probably be a lot easier with
 someone familiar with the code.

Following up again, it seems like the problem is that draw_marker is
calling set_clipbox() on the rendererBase instead of theRasterizer,
which is done at 7 other places in the code (as opposed to only one
other location for rendererBase).  Since rendererBase is used for
restore_region, this makes sense as to why it would fix my problem. I
can confirm making the change fixes my problem and doesn't cause any
other issues in my (admittedly brief so far) testing.

(If this isn't the proper fix, an alternative is to call
rendererBase.reset_clipping(true), but I really think this is working
around the issue).

Can someone more familiar with the agg backend weigh in here? I'm
pretty comfortable with the fix, but don't want to be responsible for
breaking pretty much all of matplotlib.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Help with blitting bug with subplots and markers

2010-07-02 Thread Ryan May
Hi,

I've been debugging this for hours now and could really use the help
of someone smarter than me. In working on blitting with animations,
I've run into a problem when trying to use blitting + multiple
subplots + lines with markers. It's an esoteric combination to be
sure, but I have a script (attached) that demonstrates my problem.  As
far as I can tell, the addition of a marker to a line object causes to
canvas.restore_region() to no longer function (I've paused the
animation, after a blit to flush the draw, after every stage). The
data in the region saved from copy_from_bbox is fine, but calling
restore_region() with it has no effect.  Removing marker from the line
specification causes the problem to disappear.  The net effect of the
problem is that the other subplot (than the one with the marker) does
not have the previous draw cleared, resulting in a smearing effect.

Anybody have a clue?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
#!/usr/bin/env python
# Reveals a bug in blitting with multiple subplots caused by the use of
# markers
import time

import gtk, gobject

import matplotlib
matplotlib.use('GTKAgg')

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
canvas = fig.canvas

fig.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs
ax.grid() # to ensure proper background restore
ax2.grid()

# create the initial line
x = np.arange(0,2*np.pi,0.01)
line, = ax.plot(x, np.sin(x), animated=True, lw=2, marker='o')
line2, = ax2.plot(x, np.cos(x), 'k', animated=True, lw=2)

canvas.draw()

def update_line(*args):
if update_line.background is None:
update_line.background = canvas.copy_from_bbox(ax.bbox)
update_line.background2 = canvas.copy_from_bbox(ax2.bbox)

canvas.restore_region(update_line.background)
line.set_ydata(np.sin(x+update_line.cnt/10.0))
ax.draw_artist(line)
canvas.blit(ax.bbox)

canvas.restore_region(update_line.background2)
line2.set_ydata(np.sin(x+update_line.cnt/10.0))
ax2.draw_artist(line2)
canvas.blit(ax2.bbox)

if update_line.cnt==1000:
gtk.main_quit()
raise SystemExit

update_line.cnt += 1
return True

update_line.cnt = 0
update_line.background = None

def start_anim(event):
gobject.timeout_add(100, update_line)
canvas.mpl_disconnect(start_anim.cid)

start_anim.cid = canvas.mpl_connect('draw_event', start_anim)

plt.show()
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel