From: Matt Auger <mauger@ph...>  20070225 22:43:00

The trick is that you want the image coordinates in *screen* coordinates, not printer coordinates. The image coordinates will be screen coordinates if you obtain the imgheight/imgwidth by multipying the figure height/width by 80, not 100. The DPI won't matter if you are manually setting the height/width in the img tag. Alternatively, you could set dpi=80 and skip the imgheight/imgwidth entries altogether (and reformat the vertices correctly for the imagemap input without using the imgheight...). If for some reason you want the displayed image to be larger/smaller than the selected size (here 4inx4in), multiply the matplotlib coordinates by the ratio of the image scaling factor and 80. Ie in your example, multiply the coordinates by 100./80. to obtain the correct coordinates for the image size that you have chosen (here 400pix/400pix instead of the 'natural' size of 320x320 based upon the PNG being a 4"x4" image). Matt Rajarshi Guha3 wrote: > > Hi, I'm trying to generate a barplot and subsequently dumping it to a > PNG file and making an HTML imagemap out of it. I've pasted my code > below. > > The problem is that the coordinates I need to supply for the imagemap > don't seem to be correct. > > I'm getting the screen coordinates using: > > coords = [] > for rectangle in b: > > vertices = rectangle.get_verts() > > top_left = get_top_left(vertices) > lower_right = get_lower_right(vertices) > > trans = rectangle.get_transform() > top_left = trans.xy_tup(top_left) > lower_right = trans.xy_tup(lower_right) > > coords.append( (top_left, lower_right) ) > > >  View this message in context: http://www.nabble.com/tryingtogetscreencoordinatesforbarstf3280553.html#a9150522 Sent from the matplotlib  users mailing list archive at Nabble.com. 