Remove border with matplotlib pcolor

How to remove the white border around the top and right of this graph?

this is the code i use to build my pandas DataFrame:

plt.pcolor(diff,clip_on=False) # diff is a DataFrame
plt.yticks(np.arange(0.5, len(diff.index), 1), diff.index)
plt.xticks(np.arange(0.5, len(diff.columns), 1), diff.columns, rotation=90)
plt.colorbar()

pcolor plot

+4
source share
1 answer

Try to set the axis limits according to the data. A faster interface - via pyplot functions - I think you want:

plt.ylim(0, len(diff.index))
plt.xlim(0, len(diff.columns))

but if you save the return value from pcolor, you can also set limits.

h = plt.pcolor(diff,clip_on=False) # diff is a DataFrame
h.axes.set_ylim(0, len(diff.index))
+6
source

Source: https://habr.com/ru/post/1526534/


All Articles