如何摆脱matplotlib色彩映射中的额外行?

时间:2012-08-03 17:04:48

标签: python matplotlib

我在matplotlib中创建了以下colormap:

Colormap

我无法弄清楚如何摆脱额外的行,也不知道是什么导致它。

我的代码如下:

# Create colormap
c = pcolor(data)
set_cmap('jet')
c = pcolor(data, edgecolors='w',linewidths = '3')

# Set x and y-axes
xticks = np.arange(.5,len(x_labels),1)
xlabels = x_labels
plt.xticks(xticks, xlabels)
xlabel('Species')
yticks = np.arange(.5,len(y_labels),1)
ylabels = y_labels
plt.yticks(yticks, ylabels)
ylabel('Experiments')

# Set the range of values to between 0 and 1
plt.clim(-1,1)
#colorbar()
# Either save to file or show
if filename:
    savefig(filename + '.png')
else:
    show()

2 个答案:

答案 0 :(得分:1)

克里斯的明确回答总能奏效。另一种解决方案是告诉matplotlib你想要什么,让系统处理细节。你想要一个紧轴,所以插入

axis('tight')
show()之前

。或者axis(image)也可以起作用,这可以说是让细胞成为正方形的令人愉快的副作用。

答案 1 :(得分:0)

如何使用matplotlib.pyplot.ylim(ymax=7.5)更改y轴限制。

相关问题