 # 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