简体   繁体   English

Python将2d数据绘制到3d轴上

[英]Python plotting 2d data on to 3d axes

I've had a look at matplotlib's examples of 3d plots , but none of these give me what I want to plot, something like: 我已经看过matplotlib的3d图的例子了 ,但这些都没有给我我想要绘制的内容,例如:

在此输入图像描述

The plot shows a series of measurements on the y-axis (N) and each measurement has an intensity spectrum (p/2hk_L), ie N is fixed for each line you see in the graph. 该图显示了y轴(N)上的一系列测量值,每个测量值都有一个强度谱(p / 2hk_L),即对于您在图中看到的每条线,N是固定的。 What is the easiest function to use to plot data like this? 用于绘制这样的数据的最简单函数是什么?

Here is a try: 这是一个尝试:

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x = np.linspace(-50,50,100)
y = np.arange(25)
X,Y = np.meshgrid(x,y)
Z = np.zeros((len(y),len(x)))

for i in range(len(y)):
    damp = (i/float(len(y)))**2
    Z[i] = 5*damp*(1 - np.sqrt(np.abs(x/50)))
    Z[i] += np.random.uniform(0,.1,len(Z[i]))
ax.plot_surface(X, Y, Z, rstride=1, cstride=1000, color='w', shade=False, lw=.5)

ax.set_zlim(0, 5)
ax.set_xlim(-51, 51)
ax.set_zlabel("Intensity")
ax.view_init(20,-120)
plt.show()

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM