简体   繁体   English

Python: pandas 3d Z6A8064B5DF479455500553C47C55057,YD,

[英]Python: pandas 3d dataframe into X,Y,Z

I have my csv data read by pd.read_csv ( https://www.pkks.de/contourN.dat ):我有我的 csv 数据由pd.read_csv读取( https://www.pkks.de/contourN.dat ):

         0        1         2
0     -3.0 -3.00000 -0.001395
1     -3.0 -2.97647 -0.001410
2     -3.0 -2.95294 -0.001421
3     -3.0 -2.92941 -0.001426
4     -3.0 -2.90588 -0.001427
...    ...      ...       ...
65531  3.0  2.90588 -0.001427
65532  3.0  2.92941 -0.001426
65533  3.0  2.95294 -0.001421
65534  3.0  2.97647 -0.001410
65535  3.0  3.00000 -0.001395

which represents (x,y,z) coordinates.表示 (x,y,z) 坐标。 How must I convert these data into X, Y, Z variables to plot a surface with matplotlib:我必须如何将这些数据转换为X, Y, Z变量到 plot 表面与 matplotlib:

ax.plot_surface(X, Y, Z, ...)
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

data = pd.read_csv('your_file.csv', sep=',', names=['X', 'Y', 'Z'], index_col=False)

x_num = len(data['X'].unique())
y_num = len(data['Y'].unique())

x = data['X'].values.reshape(x_num, -1)
y = data['Y'].values.reshape(y_num, -1)
z = data['Z'].values.reshape((x_num, y_num))

fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(x, y, z)

暂无
暂无

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

相关问题 使用“索引”和“列”作为X,Y和值作为Z,将pandas DataFrame转换为3d图形? - Convert pandas DataFrame to a 3d graph using Index and Columns as X,Y and values as Z? 在python中卷积具有三个内核(x,y,z)的3D数组 - Convolve a 3D array with three kernels (x, y, z) in python python中的3D体积杂技。在3D numpy数组中选择x / y / z行/列 - 3D volume acrobatics in python.. selecting x/y/z rows/columns in 3D numpy arrays 3d将x,y,z坐标转换为3d numpy数组 - 3d coordinates x,y,z to 3d numpy array 当Z是Python中的列表列表时,如何用X,Y,Z绘制3D曲面? - How to plot 3D surface with X, Y, Z when Z is a list of list in Python? Python-如何在表面离散3D点(x,y,z)之后从给定的x,y获取z值 - Python - How to get z value from given x, y after surface discrete 3D points (x,y,z) DataFrame:如何使用索引和列作为 x 和 y,数据作为 z 来绘制 3D 图? - DataFrame: how to draw a 3D graph using Index and Columns as x and y, and data as z? Python,Axes3D,绘图:无法附加到我的3D散点图中的X,Y,Z值列表 - Python, Axes3D, plotting: Cannot append to List of X,Y,Z values in my 3D scatterplot Python:创建 X、Y 坐标和相应的计算 Z 值的网格以生成 XYZ 的 3D 数组 - Python: Creating a Grid of X,Y coordinates and corresponding calculated Z values to result in a 3D array of XYZ 在python中从{x,y,z} - 散射数据绘制3D表面 - Plot a 3D surface from {x,y,z}-scatter data in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM