Here is my example:
import numpy as np
import matplotlib.pyplot as plt
a1 = np.random.randn(10000)
b1 = np.random.randn(10000)
a2 = np.random.randn(5000)
b2 = np.random.randn(5000)
fig, axs = plt.subplots(1, 2, figsize=(9, 4))
ax = axs[0]
m = ax.hist2d(a1, b1, bins=30)
fig.colorbar(m[3], ax=ax)
ax = axs[1]
m = ax.hist2d(a2, b2, bins=30)
fig.colorbar(m[3], ax=ax)
plt.tight_layout()
The output figure is like this:
My question is how can I change the color range of the right figure, so that its maxium color values is 115
instead of 66
?(Note: Not just change the values of colorbar, the color of the same color values should be same with the left figure.)
I tried set the cmax keywords like this:
m = ax.hist2d(a2, b2, bins=30, cmax=115)
But the results have no change. So how should I do?