On 8/31/07, Romain Bignon <[EMAIL PROTECTED]> wrote: > Hello, > > I want to get pixels position of a Text object on my imagine, but there isn't > any methods of this class to get them. > > How can I do ?
You can use the t.get_window_extent() method of the text object, with the caveat that this only works *after* the canvas has been drawn, so you need to force a draw first. Makre sure you use the same DPI in the figure and savefig commands if you need these coords for working with hardcopy from pylab import figure, show fig = figure(figsize=(6,6), dpi=72) ax = fig.add_subplot(111) ax.plot([1,2,3]) t = ax.text(1,2,'hi') fig.canvas.draw() left, bottom, width, height = t.get_window_extent().get_bounds() print left, bottom, width, height fig.savefig('test', dpi=72) # make sure you use the same DPI if you save show() ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users