From: David G. <Dav...@no...> - 2006-10-30 06:19:09
|
Hi! OK, loc=(a,b) positions the legend, and appears to place the lower left corner at (a,b) (axes coords.), right? Is there some way to say that (a,b) should specify the location of, say, the center of the legend? Thanks! DG |
From: John H. <jdh...@ac...> - 2006-10-30 14:34:27
|
>>>>> "David" == David Goldsmith <Dav...@no...> writes: David> Hi! OK, loc=(a,b) positions the legend, and appears to David> place the lower left corner at (a,b) (axes coords.), right? yes David> Is there some way to say that (a,b) should specify the David> location of, say, the center of the legend? Thanks! Afraid not. JDH |
From: David G. <Dav...@no...> - 2006-10-30 15:23:20
|
John Hunter wrote: >>>>>> "David" == David Goldsmith <Dav...@no...> writes: >>>>>> > > David> Hi! OK, loc=(a,b) positions the legend, and appears to > David> place the lower left corner at (a,b) (axes coords.), right? > > yes > > David> Is there some way to say that (a,b) should specify the > David> location of, say, the center of the legend? Thanks! > > Afraid not. > OK, I was afraid of that; in that case, is there some way to get the height and width of the legend (so I can do what I want programatically)? Thanks again, DG > JDH > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: John H. <jdh...@ac...> - 2006-10-30 15:31:31
|
>>>>> "David" == David Goldsmith <Dav...@no...> writes: David> OK, I was afraid of that; in that case, is there some way David> to get the height and width of the legend (so I can do what David> I want programatically)? Thanks again, Again, afraid not. At least nothing obvious. The legend placement is done dynamically at draw time, and so it will be difficult to get this information ahead of time. There might be some cleverness that can be applied, but nothing easy. One option would be connect to the draw event, and then inspect the legend properties, and then place it where you want knowing the width and the height. Not too elegant, but serviceable. Here is an untested sketch def ondraw(event): if ondraw.done: return # in pixels left,bottom,width,height = leg.legendPatch.get_window_extent().get_bounds() # move your legend.... ondraw.done = True ondraw.done = False fig = figure() ax = fig.add_subplot(111) leg = ax.legend(blah) fig.canvas.mpl_connect('draw_event', ondraw) It might be better to patch legend directly to do what you want and send the patch our way. Or subclass it. JDH |
From: Christopher B. <Chr...@no...> - 2006-10-30 18:39:05
|
John Hunter wrote: > The legend placement is done dynamically at draw time, Ah, so it looks like it does make sense for the user to specify an alignment, and have it figured out at draw time. > It might be better to patch legend directly to do what you want and > send the patch our way. Or subclass it. That does seem the way to go. David, I've done stuff like this for the wxPython FloatCavnas -- perhaps I can help, if you want to do it. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: David L G. <Dav...@no...> - 2006-10-30 18:41:56
|
John Hunter wrote: >>>>>> "David" == David Goldsmith <Dav...@no...> writes: >>>>>> > > David> OK, I was afraid of that; in that case, is there some way > David> to get the height and width of the legend (so I can do what > David> I want programatically)? Thanks again, > > Again, afraid not. At least nothing obvious. The legend placement is > done dynamically at draw time, and so it will be difficult to get this > information ahead of time. Actually, I don't care (tremendously) if I have to wait 'til after it's drawn to get the info (I've already found other instances where, to do what I've wanted, I've had to draw, then get/modify/set then redraw - as you say, inelegant, but serviceable; it's not like the old days where re-drawing meant waiting half a minute) so if that info is available after the figure's been drawn, that's good enough for me (as long as it's possible to set it as well as get it) for now. Is that what legendPatch.get_window_extent().get_bounds() does? (I'll probably find out using dir before you reply, but a reply would be appreciated anyway, so the info will be in the archive). > There might be some cleverness that can be > applied, but nothing easy. > > One option would be connect to the draw event, and then inspect the > legend properties, and then place it where you want knowing the width > and the height. Not too elegant, but serviceable. Here is an > untested sketch > > > def ondraw(event): > if ondraw.done: return > # in pixels > left,bottom,width,height = leg.legendPatch.get_window_extent().get_bounds() > # move your legend.... > ondraw.done = True > ondraw.done = False > > fig = figure() > ax = fig.add_subplot(111) > leg = ax.legend(blah) > fig.canvas.mpl_connect('draw_event', ondraw) > > > It might be better to patch legend directly to do what you want and > send the patch our way. I'm getting closer to the point where I feel like I might be capable of doing this, but I'm not quite there yet. :-) > Or subclass it. > This is closer to my confidence level. Thanks! DG > JDH > -- HMRD/ORR/NOS/NOAA <http://response.restoration.noaa.gov/emergencyresponse/> |