Python:用于6系列分数数据(z)的具有固定x和y的2d等高线图

麦可

我正在尝试使用等高线图以固定的x轴(“ WN”)在6个高度(5、10、15、20、25和30)显示分数数据数组(介于0和1之间)系列,从1到2300)。每个系列的y(高度)不同,并且是不连续的,因此我需要在高度之间进行插值。

WN,5,10,15,20,25,30
1,0.9984898,0.99698234,0.99547797,0.99397725,0.99247956,0.99098486
2,0.99814528,0.99629492,0.9944489,0.99260795,0.99077147,0.98893934
3,0.99765164,0.99530965,0.99297464,0.99064702,0.98832631,0.98601222
4,0.99705136,0.99411237,0.99118394,0.98826683,0.98535997,0.9824633
5,0.99606526,0.99214685,0.98824716,0.98436642,0.98050326,0.97665751
6,0.98111153,0.96281821,0.94508928,0.92790776,0.91125059,0.89509743
7,0.99266499,0.98539108,0.97816986,0.97100824,0.96390355,0.95685524
...

有任何想法吗?谢谢!

多库马达

使用matplotlib,您需要X(行),Y(列)和Z值。matplotlib函数期望数据采用某种格式。在下面,您将看到meshgrid帮助我们获取该格式。

在这里,我使用pandas导入您保存到csv文件的数据。您可以通过任何方式加载数据。关键是为绘图功能准备数据。

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

#import the data from a csv file
data = pd.read_csv('C:/book1.csv')

#here, I let the x values be the column headers (could switch if you'd like)
#[1:] don't want the 'WN' as a value
X = data.columns.values[1:]

#Here I get the index values (a pandas dataframe thing) as the Y values
Y = data['WN']

#don't want this column in your data though
del data['WN']

#need to shape your data in preparation for plotting
X, Y = np.meshgrid(X, Y)

#see http://matplotlib.org/examples/pylab_examples/contour_demo.html
plt.contourf(X,Y,data)

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

有没有办法在等高线图的顶部放置网格线?

来自分类Dev

等高线图x标签

来自分类Dev

将构成等高线图矩阵的数据点覆盖在MATLAB中的同一图上

来自分类Dev

Python Matplotlib等高线图中的非线性缩放

来自分类Dev

R在ggplot2等高线图中添加图例和directlabel

来自分类Dev

查找最大的封闭3D等高线图

来自分类Dev

Matlab:用等高线填充等高线图

来自分类Dev

python中的一个3D图形中的多个2D等高线图

来自分类Dev

使用1D X,Y和Z变量在python中进行2D等高线图

来自分类Dev

多元高斯的等高线图

来自分类Dev

从数据框创建等高线图

来自分类Dev

填充matplotlib等高线图

来自分类Dev

填充matplotlib等高线图

来自分类Dev

八度等高线图

来自分类Dev

等高线图x标记

来自分类Dev

等高线图例-Matplotlib

来自分类Dev

在Matlab 2014b中移动等高线图的z值

来自分类Dev

同一图中有多个等高线图

来自分类Dev

R在ggplot2等高线图中添加图例和directlabel

来自分类Dev

Matlab:用等高线填充等高线图

来自分类Dev

Matplotlib等高线图上颜色栏的Python最小和最大范围

来自分类Dev

Gnuplot-在2D等高线图上绘制数据点

来自分类Dev

使用函数绘制等高线图

来自分类Dev

坏等高线图

来自分类Dev

条件等高线图

来自分类Dev

平滑边缘等高线图

来自分类Dev

使用固定输入变量进行回归预测的等高线图

来自分类Dev

Python 中 matplotlib 等高线图的 ValueError

来自分类Dev

散景中的等高线图