I have the following Python code which I am using to plot a filled contour plot:
def plot_polar_contour(values, azimuths, zeniths):
theta = np.radians(azimuths)
zeniths = np.array(zeniths)
values = np.array(values)
values = values.reshape(len(azimuths), len(zeniths))
r, theta = np.meshgrid(zeniths, np.radians(azimuths))
fig, ax = subplots(subplot_kw=dict(projection='polar'))
ax.set_theta_zero_location("N")
ax.set_theta_direction(-1)
cax = ax.contourf(theta, r, values, 30)
autumn()
cb = fig.colorbar(cax)
cb.set_label("Pixel reflectance")
show()
This gives me a plot like:

However, when I add the line ax.plot(0, 30, 'p') just before show() I get the following:

It seems that just adding that one point (which is well within the original axis range) screws up the axis range on the radius axis.
Is this by design, or is this a bug? What would you suggest doing to fix it? Do I need to manually adjust the axis ranges, or is there a way to stop the extra plot command doing this?
If the axis auto-scaling mode isn’t explicitly specified,
plotwill use “loose” autoscaling andcontourfwill use “tight” autoscaling.The same things happens for non-polar axes. E.g.
You have a number of options.
ax.axis('image')orax.axis('tight')at some point in the code.scalex=Falseandscaley=Falseas keyword arguments toplot.The easiest and most readable is to just explicitly call
ax.axis('tight'), i.m.o.