1

我在 matplotlib 中创建了以下颜色图:

颜色图

我不知道如何摆脱多余的行,也不知道是什么原因造成的。

我的代码如下:

# 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()
4

2 回答 2

1

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

axis('tight')

之前show()。或者axis(image)也有效,可以说是使细胞呈方形的令人愉快的副作用。

于 2012-08-05T07:59:04.010 回答
0

matplotlib.pyplot.ylim(ymax=7.5)使用.更改 y 轴限制怎么样?

于 2012-08-03T17:12:14.717 回答