Plotting points on images - axes problems

Hi,

Using matplotlib 0.87.2, I've been trying to plot points on top of an image. The image without points fills axes of the extent requested, but using plot to add a point on top of the image changes the axes lengths and gives unwanted white margins around the edges. Here's an example. Any help would be greatly appreciated!

Bob Simpson

from pylab import *

# Sample image.
image = rand(12,6)

# This choice for extent works fine... It produces no white margins.
#extent = [-80, 60, -60, 40]

# This choice gives unwanted white margins,
# except when no point is plotted.
extent = [-80.,64., -74.,48.]

ax1 = axes()
ax1.im = imshow(image, origin='lower', extent=extent)

# Plot point on image.
hold(True)
ax1.plot([0.0],[0.0],'wo')

show()

Bob,

Try doing

b = axis()
ax1.plot([0.0],[0.0],'wo')
axis(b)

That saves the axis range set by imshow and restores it after the call to plot.

Eric

Robert Simpson wrote:

ยทยทยท

Hi,

Using matplotlib 0.87.2, I've been trying to plot points on top of an image. The image without points fills axes of the extent requested, but using plot to add a point on top of the image changes the axes lengths and gives unwanted white margins around the edges. Here's an example. Any help would be greatly appreciated!

Bob Simpson

from pylab import *

# Sample image.
image = rand(12,6)

# This choice for extent works fine... It produces no white margins.
#extent = [-80, 60, -60, 40]

# This choice gives unwanted white margins,
# except when no point is plotted.
extent = [-80.,64., -74.,48.]

ax1 = axes()
ax1.im = imshow(image, origin='lower', extent=extent)

# Plot point on image.
hold(True)
ax1.plot([0.0],[0.0],'wo')

show()

-------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users