I have the following lines of code to generate a heatmap (pcolormesh
).
import matplotlib.pyplot as plt
import numpy as np
vals = np.linspace(-np.pi/2, np.pi/2, 101)
x, y = np.meshgrid(vals, vals)
z = np.abs(np.sinc(x) * np.sinc(y))
xDeg = np.rad2deg(x)
yDeg = np.rad2deg(y)
plt.pcolormesh(xDeg, yDeg, z, cmap='jet', vmin=0, vmax=1)
plt.colorbar()
plt.axis([-90, 90, -90, 90])
ticks = np.linspace(-90, 90, 13)
plt.xticks(ticks)
plt.yticks(ticks)
mean = np.mean(z) # 0.186225110029
rms = np.sqrt(np.mean(z**2)) # 0.295710882276
plt.show()
I'd like to place:
Any input?
That was easier than expected. I didn't realize colorbar has a plottable axis in plt.colorbar().ax
cb = plt.colorbar()
cb.ax.plot(0.5, mean, 'w.')
cb.ax.plot([0, 1], [rms]*2, 'w')
OR, as @OrOrg pointed out,
cb = plt.colorbar()
cb.ax.plot(0.5, mean, 'w.')
cb.ax.axhline(rms, c='w')
Looks like the x-axis is (0, 1) and y-axis (dataMin, dataMax) (0, 1).
Per @S.A. comment, x/y-axis are between (min(data), max(data))
. However, this example is showing the x-axis is (0, 1)
where x-axis data is (-pi/2, pi/2)
. Y-axis is confirmed to be (min(data), max(data))
.