我有一组大约2000个文件,看起来像:10_20.txt
,10_21.txt
,10_21.txt
。。。,10_50.txt
。。。,11.20.txt
。。。,11.50.txt
。。。,20_50.txt
文件名中的第一个值,我们将称为x
,从10到20的步骤为1,而文件名中的第二个值,我们将称为y
,从20到50,以1为步进。在
在这些文件中,有一堆值和另一个我要提取的值,我们称之为z
。在
{10>循环从CDI文件中提取一个文件并添加到列表中。在
我现在的问题是,如果我有2个numpy
数组,它们看起来像:
x = np.arange(10,20,1)
y = np.arange(20,50,1)
如果一个z
列表中有~2000floats
,那么绘制z
如何依赖x
和{
我一直在想最好是从文件中提取x
、y
和{x
和y
值的正确方向。在
假设您有一个ready函数,比如
read_z_from_file(filename)
,它返回文件中包含的z
-值,可以这样做:然后您可以用
^{pr2}$imshow
或matplotlib
来可视化z
。例如:编辑:
为了回答OP的问题,有多种方法可以可视化您的数据。
imshow
和matshow
两者都有相同的功能,但显示细节不同。此外,您还可以生成等高线图或三维曲面。这在很大程度上取决于你想看什么。不管怎样,假设上面的代码能满足您的需要,我在下面展示一些使用四种不同方法来显示相同示例数据的代码。您可以在内置的help()
函数以及matplotlib和numpy文档页面中找到关于这些不同方法的更多信息。在最后的情节如下:
使用x和y作为坐标,并为能量z设置一个点
一个表格也可以,因为你还没有说明x和y几何图形除了作为标签外还有其他的数值用途。在
相关问题 更多 >
编程相关推荐