Вопрос

I have attempted to move my yticks on the heat map below to the centre of the row it corresponds to.

This has worked, except for the fact I now get the white space at the bottom of the graph. Is there a way to achieve the ticks in the middle without the white space?

Original image & code:

enter image description here

heatmap = plt.pcolor(df2.T, cmap=cmap,  vmax=1, vmin=0)
plt.yticks(range(len(df2.columns )+1), o, size=15)

New Image & Code

enter image description here

heatmap = plt.pcolor(df2.T, cmap=cmap,  vmax=1, vmin=0)
plt.yticks(np.arange(0.5, len(df2.columns)+1,1), df2.columns, size=15)

Attempts

I have tried using

plt.yticks(np.arange(0.5, len(df2.columns)+0.5,1), o, size=15

Note the change from +1 to +0.5 This however, halves my bottom row. See below:

enter image description here

Это было полезно?

Решение

You can use ylim to set the yaxis range:

plt.ylim(0, df2.shape[1])
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top