1
我正在使用matplotlib繪製一個3D直方圖,其中包含角度輻射角的正弦和餘弦值的線框。該地塊形成圓形,因爲它應該:Matplotlib三維繪圖忽略不在圈中的值
現在我想只是有圓形和山丘繪製,但不是在圈和周圍的值。 我試圖與
hist[hist==0] = np.nan
駁回每個值是零,但後來我的情節是這樣的,其中在圈內也有一些值均爲零,因此線框情節不「觸地」了。
那麼,有沒有辦法解僱在圈內和周圍但情節仍下降到零,一路值是多少?
這是我的代碼:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
cos, sin = np.genfromtxt('out_dhdrls_test0123.csv', delimiter=' ').transpose()
hist, xedges, yedges = np.histogram2d(cos, sin, bins=50, range=[[-1, 1], [-1, 1]])
hist[hist==0] = np.nan
xpos, ypos = np.meshgrid(xedges[:-1], yedges[:-1])
zpos = np.zeros_like(xpos)
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')
ax.plot_wireframe(xpos, ypos, hist)
plt.show()