TourEiffel
TourEiffel

Reputation: 4424

Custom HeatMap Issue on Scale and legend

I try to create a custom heatmap but have an issue on the y scale.

The code I built is the following one :

cmap = colors.ListedColormap(['red','green'])
bounds=[-1,1]
norm = colors.BoundaryNorm(bounds, cmap.N)
heatmap = plt.pcolor(np.array(result), cmap=cmap, norm=norm)
plt.colorbar(heatmap, ticks=[-1,0,1])

Where result is an array of 3 Column 6 Row Which contains -1 or 1 values

enter image description here

How can I edit it in order to get

0 1 2 3 

enter image description here

Upvotes: 1

Views: 33

Answers (1)

Dinari
Dinari

Reputation: 2557

You can modify the tick range and frequency:

plt.xticks(np.arange(0, 4, 1.0))

Will make ticks from 0 to 4 (excluding 4, so until 3), with an interval of 1 between them.

Upvotes: 1

Related Questions