Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get tick values of colorbar in matplotlib

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()
like image 320
a.smiet Avatar asked Aug 04 '17 13:08

a.smiet


1 Answers

In version 2.1 of matplotlib colorbar.get_ticks() method was introduced.

like image 105
pcu Avatar answered Oct 03 '22 08:10

pcu