【发布时间】:2017-04-26 09:40:01
【问题描述】:
我正在使用 matplotlib 绘制一个 3D“直方图”,其中包含角度辐射的正弦和余弦值的线框。该图应形成一个圆圈:
现在我试图只绘制圆圈及其山丘,但不绘制圆圈及其周围的值。 我试过用
来消除每个为零的值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()
【问题讨论】:
标签: python numpy matplotlib plot