I am trying to overlay a scatter plot onto a contour plot using matplotlib, which contains
plt.contourf(X, Y, XYprof.T, self.nLevels, extent=extentYPY, \
origin = 'lower')
if self.doScatter == True and len(xyScatter['y']) != 0:
plt.scatter(xyScatter['x'], xyScatter['y'], \
s=dSize, c=myColor, marker='.', edgecolor='none')
plt.xlim(-xLimHist, xLimHist)
plt.ylim(-yLimHist, yLimHist)
plt.xlabel(r'$x$')
plt.ylabel(r'$y$')
What ends up happening is the resulting plots extend to include all of the scatter points, which can exceed the limits for the contour plot. Is there any way to get around this?
xLimHistandyLimHistand show how / where they are calculated? When I make my own contour plot and then overlay scatter points, your code works correctly. If I definexLimHistandyLimHistin such a way that it should exclude some of the scatter points, then the plot does indeed exclude those and it does not fit itself to contain all scatter points. So my guess is that you're definingxLimHistandyLimHistincorrectly.