我有一些网格数据,比如下面的pressure.txt。我希望我能画一张等高线图。我已经完成了代码。但似乎有一些问题,比如在我的图中,左下角有一块白色。我不知道为什么。

代码如下:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
a1,b1,c1 = np.loadtxt("pressure.txt", unpack=True)
a2,b2,c2 = np.loadtxt("temperature.txt", unpack=True)
a3,b3,c3 = np.loadtxt("sl.txt", unpack=True)
x1=a1.reshape(51,16)
y1=b1.reshape(51,16)
z1=c1.reshape(51,16)
fig, (ax1,ax2,ax3) = plt.subplots(figsize=(12,8), ncols=3)
cet1=ax1.contourf(x1, y1, z1, 100, cmap="jet")
ax1.set_aspect(aspect=1)
ax1.set_title("Pressure, [MPa]", fontname='Helvetica', fontsize = 12)
cet1_bar=fig.colorbar(cet1, ax=ax1, aspect=60)
cet1_bar.outline.set_visible(False)
ax1.set_xticks([0,2.5,5])
plt.setp(ax1.get_xticklabels(), fontsize=12, fontname="Times New Roman")
plt.setp(ax1.get_yticklabels(), fontsize=12, fontname="Times New Roman")
plt.savefig("Fig01.png",dpi=1000, bbox_inches='tight')
plt.show()这是preesure.txt文件:
0 0 1.77019175
0.166666657 0 1.768095875
0 0.100000001 1.715081125
0.166666657 0.100000001 1.713992063
0.333333313 0 1.766
0.333333313 0.100000001 1.712870938
0.49999997 0 1.766
0.49999997 0.100000001 1.713170156
0.833333254 0 1.766
0.833333254 0.100000001 1.714740406
1.166666627 0 1.766
1.166666627 0.100000001 1.716890156
1.499999881 0 1.766
1.499999881 0.100000001 1.724811125
1.874999881 0 1.766
1.874999881 0.100000001 1.736053
2.249999762 0 1.766
2.249999762 0.100000001 1.742682156
2.624999762 0 1.766
2.624999762 0.100000001 1.746366844
2.999999762 0 1.766
2.999999762 0.100000001 1.753380719
3.399999857 0 1.766
3.399999857 0.100000001 1.760403219
3.799999952 0 1.766
3.799999952 0.100000001 1.762016344
4.199999809 0 1.766
4.199999809 0.100000001 1.76242775
4.599999905 0 1.766
4.599999905 0.100000001 1.762552344
5 0 1.766我必须删除pressure.txt中的一些数据。我不知道如何上传文件,所以我必须在我的问题中粘贴部分内容。
发布于 2020-03-23 03:59:29
我已经找到了我的问题的关键点。我应该在"Pressure.txt“中对数据进行排序。我已经试过修复它了。每列数据从小到大排列,不会出现问题。我的意思是,第一列和第二列是用来定位位置的。
https://stackoverflow.com/questions/60790591
复制相似问题