1

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

TourEiffel
  • 4,034
  • 2
  • 16
  • 45

1 Answers1

1

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.

Dinari
  • 2,487
  • 13
  • 28