所需图像 [
我的CSV数据由X轴值,Y轴值和硬度值组成,我想绘制平滑的热图,而不是在类似的方框中绘制。
导入cv2 从skimage.io导入imread,imshow 从skimage.transform导入调整大小 将numpy导入为np 导入matplotlib.pyplot作为plt 导入matplotlib.image作为mpimg 导入球 导入操作系统 从tqdm导入tqdm 将熊猫作为pd导入 将seaborn导入为sns 从sklearn.neighbors导入KernelDensity 从mpl_toolkits.mplot3d导入Axes3D 从matplotlib导入样式 从astropy.convolution导入卷积,Gaussian2DKernel 从scipy.ndimage.filters导入gaussian_filter
path = r"C:\Users\patels\Desktop\Ti/"
ids = os.listdir(path)
#print(ids)
for n, id_ in tqdm(enumerate(ids), total=len(ids)):
data = pd.read_excel(path+id_)
print(path+id_)
df1 = data[['HV 0.2', 'X pos. [mm]', 'Y pos. [mm]']]
heatmap1_data = pd.pivot_table(df1, values='HV 0.2', index=['Y pos. [mm]'], columns='X pos. [mm]')
plt.figure() #this creates a new figure on which your plot will appear
heatmap1 = sns.heatmap(heatmap1_data, cmap="viridis", vmin=300, vmax=400)
plt.title(ids[n]+'Ti Hardness Map')