If I'm generating a colorbar for an imshow
plot, sometimes I end up with a result that includes only one tick-mark --- making the scale fairly indeterminate. Is there a way to ensure that at least 2 tick marks will be present? For example, making sure that at least both ends of the scale are labeled?
For example:
Code to reproduce:
import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
SIZE = [100,100]
MIN = 0.2
tt = np.square(np.random.uniform(size=SIZE))
for ii in range(SIZE[0]):
for jj in range(SIZE[1]):
while( tt[ii,jj] < MIN ): tt[ii,jj] = np.random.uniform()
ran = [ np.min(tt), np.max(tt) ]
print ran
use_norm = mpl.colors.LogNorm()
use_norm.vmin = ran[0]
use_norm.vmax = ran[1]
plt.imshow(tt, norm=use_norm)
plt.colorbar()
plt.show()
which produces something like: