3

I am plotting a georeferenced image with

import numpy as np
from matplotlib import pyplot as plt

f = plt.figure()
ax = f.add_subplot(111)
ax.imshow( numpy.dstack((R,G,B)), extent=[xmin,xmax,ymin,ymax] )

Then I am plotting (on the same axes instance) a two arrays x and y which only covers a small extent of the figure:

ax.plot( x, y )

I want the size of my picture to match that of the line, but I cannot remove the extent kwarg from the RGB image, otherwise I would lose the coordinates matching. What I tried to do is

ax.set_xlim( [x.min(), x.max()] )

but it is does not affect the figure. The axes limits I get is stull that of the extent keyword in the imshow method.

How do I set the axis limits without removing the extent named argument from the imshow call? I don't want to reproject my x and y coordinates.

fmonegaglia
  • 2,749
  • 2
  • 24
  • 34
  • You probably need to call `fig.canvas.draw_idle()` or update to mpl > 1.5.1. Mutating objects does not trigger a re-draw (and this is a feature not a bug). – tacaswell Mar 29 '16 at 12:40
  • 1.5.1 is the latest stable version. `f.canvas.draw_idle()` does not work for me – fmonegaglia Mar 29 '16 at 12:44

0 Answers0