python三维数据图_matplotlib中三维数据的热图
我想用我的三維數據生成一張熱圖。在
我已經能夠用這些數據繪制出trisurf。在
有人能幫我制作熱圖嗎?我看到了在線教程,但是它們對3D來說都很復雜,我在這個網站上找到了一個在matplotlib中生成帶有散點的熱圖,但是它只有2D數據。在
我生成trisurf的代碼是from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
n_angles = 36
n_radii = 8
# An array of radii
# Does not include radius r=0, this is to eliminate duplicate points
radii = np.linspace(0.125, 1.0, n_radii)
# An array of angles
angles = np.linspace(0, 2*np.pi, n_angles, endpoint=False)
# Repeat all angles for each radius
angles = np.repeat(angles[...,np.newaxis], n_radii, axis=1)
# Convert polar (radii, angles) coords to cartesian (x, y) coords
# (0, 0) is added here. There are no duplicate points in the (x, y) plane
x,y,z =np.loadtxt('output/flash_KR_endowment_duration_3D.dat',delimiter='\t',usecols=(0,1,2),unpack=True)
#x,y,z =np.loadtxt('output/disk_KR_endowment_duration_3D.dat',delimiter='\t',usecols=(0,1,2),unpack=True)
fig = plt.figure()
ax = fig.gca(projection='3d')
#fig.suptitle(suptitle, fontsize=12, fontweight='bold')
#ax.set_title("Disk Kryder's Rate-Endowment-Duration Plot",fontsize=12)
ax.set_title("Flash Kryder's Rate-Endowment-Duration Plot",fontsize=12)
ax.set_xlabel("Kryder's rate")
ax.set_ylabel("Duration")
ax.set_zlabel("Endowment")
surf = ax.plot_trisurf(x, y, z, cmap=cm.jet, linewidth=0.2)
fig.colorbar(surf, shrink=.7, aspect=20)
plt.show()
數據為3列。比如說X,Y,Z。我試過用顏色繪制三維散點圖。但我在找熱圖。在
總結
以上是生活随笔為你收集整理的python三维数据图_matplotlib中三维数据的热图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 线型_CCF 202006
- 下一篇: 机油壳多少钱啊?