From: Brendan Barnwell <brenbarn@br...>  20100214 19:19:15

Brendan Barnwell wrote: > I'm trying to find the quickest way to erase a rectangular area of > the figure canvas. I tried using canvas.restore_region with the > optional bbox argument, but there seems to be some mismatch between > the measurement units of the saved buffer object and the currently > shown data. For instance, if I have a Text object on my plot, I tried > this: > > bbox = g.text.get_window_extent() > canvas.restore_region(background, bbox) > > . . . but it does not correctly block out the text. (The restored > rectangle from the background appears elsewhere on the axes.) How can > I convert the buffer coordinates to the coordinates of the the > displayed plot? I'm sorry to bump my own post, but I would really appreciate some help with this. I've been wrestling with it for a couple days now, and I cannot figure out how the coordinate system of the saved canvas is related to the axes coordinates. I have found that with bbox.transformed(ax.transData) I can at least get the coordinates scaled to fit on the axes, but they are still offset in position from where the box actually appears on the canvas. I can't figure out how to compute this offset. By playing around with the coordinates manually, for instance, I've found that adjusting x by 52 and y by 21 appears to line up the canvas with the axes, but I can't see where these numbers 52 and 21 would come from. My saved canvas buffer's get_extents() method returns (65, 50, 586, 443), so I thought that the appropriate offsets would be 65 and 50, but that doesn't work. So, what coordinates (x1, y1, x2, y2) do I need to use in canvas.restore_region(savedBuffer, (x1, y1, x2, y2)) in order to restore precisely the area of canvas occupied by a patch drawn at axis coordinates (a1, b1, a2, b2)? Thanks?  Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." author unknown 