Get tick values of colorbar in matplotlib

Viewed 5916

How can I extract the currently displayed ticks of a matplotlib colorbar as a list? With this example I should get the the list with floats[-0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6]

import matplotlib.pyplot as plt
import numpy as np

img = np.random.normal(0, 0.2, size=(100,100))
plt.imshow(img)
plt.colorbar()
plt.show()
2 Answers
Related