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.