- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在尝试获取数据阵列的曲面图时遇到问题。 (请参阅下面的小测试数据样本)。
这是我用来测试我遇到的不同方法的基本代码。
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
data = np.loadtxt('lobe1.dat')
xs = data[:,0]
ys = data[:,1]
zs = data[:,2]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(xs,ys,zs, rstride=1, cstride=1,color='b')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim([-0.08,0.08])
ax.set_ylim([-0.08,0.08])
ax.set_zlim([-0.08,0.08])
ax.set_aspect("equal")
plt.show()
在这个版本中,我得到了一个绘图轴,但数据丢失了。我已将其缩小到 xs
、ys
、zs
需要是二维数组这一事实。我可以使用 np.meshgrid
来转换 xs
,ys
但我如何处理 zs
?即:
xs,ys = np.meshgrid(xs, ys)
zs = ???
我还遇到了解决方案 here,它建议使用下面的代码并绘制新的 X、Y、Z(可能使用一些数组排序),但这会引发
ValueError: total size of new array must be unchanged
在调用 xs.reshape()
时。
cols = np.unique(xs).shape[0]
X = xs.reshape(-1, cols)
Y = ys.reshape(-1, cols)
Z = zs.reshape(-1, cols)
这让我很困惑,所以我很感激任何输入。通常我要处理一个大得多的数据集,但这里有一些来自 lobe1.dat
的样本数据,可以让您重现我的问题。每列分别由xs
、ys
和zs
组成。
0.000000000000000 0.000000000000000 -0.049815118005748
0.039186360495468 0.000000000000000 -0.038410316117142
0.056803651667469 0.000000000000000 -0.024791146049150
0.072097497329379 0.000000000000000 -0.007246071120158
0.067060501396178 0.000000000000000 0.013688667526320
0.051379603016815 0.000000000000000 0.029664027632614
0.031789354260577 0.000000000000000 0.042385805680769
0.000000000000000 0.000000000000000 -0.049815118005748
0.033152869816836 0.019140818313159 -0.037523509346281
0.045829649529645 0.026459760492807 -0.023095972443560
0.052288905121942 0.030189013447784 -0.006068220024078
0.050910857853398 0.029393397486334 0.011999804274721
0.042289602909023 0.024415913623447 0.028193068606016
0.027154245218747 0.015677510786684 0.041806695431158
0.000000000000000 0.000000000000000 -0.049815118005748
0.018422854617625 0.031909320218181 -0.036116018976805
0.024307976693871 0.042102650662984 -0.021217741560168
0.026764953958725 0.046358260118753 -0.005379958170438
0.026279549165091 0.045517514353942 0.010728581020809
0.022786184948649 0.039466830041721 0.026311220027814
0.015304154209252 0.026507572657293 0.040811077891338
0.000000000000000 0.000000000000000 -0.049815118005748
0.000000000000000 0.036309017710339 -0.035589956059286
0.000000000000000 0.047273292454049 -0.020631756287663
0.000000000000000 0.051675786366447 -0.005193611943154
0.000000000000000 0.050815730690458 0.010372717591526
0.000000000000000 0.044489633172666 0.025686101688387
0.000000000000000 0.030316588229639 0.040422117639519
-0.000000000000000 0.000000000000000 -0.049815118005748
-0.018496134334071 0.032036244410230 -0.036259675955309
-0.024429654459698 0.042313402735548 -0.021323950621558
-0.026908703737555 0.046607242039264 -0.005408852963170
-0.026418888079279 0.045758856432786 0.010785465894322
-0.022894621383867 0.039654647456911 0.026436431637941
-0.015355646960057 0.026596760717909 0.040948391893486
-0.000000000000000 0.000000000000000 -0.049815118005748
-0.033286051232919 0.019217710639585 -0.037674248456914
-0.045779044607711 0.026430543727506 -0.023070469960026
-0.051867788406975 0.029945881599038 -0.006019348683662
-0.050596024278383 0.029211628237049 0.011925597289441
-0.042339044284962 0.024444458615154 0.028226029523308
-0.027273140887785 0.015746155233209 0.041989747288558
-0.000000000000000 0.000000000000000 -0.049815118005748
-0.039273413070914 0.000000000000000 -0.038495644708504
-0.055872341877765 0.000000000000000 -0.024384689134220
-0.065935779675748 0.000000000000000 -0.006626795195273
-0.063568190701275 0.000000000000000 0.012975802590838
-0.051006846275802 0.000000000000000 0.029448816427848
-0.031916472879064 0.000000000000000 0.042555297172085
-0.000000000000000 -0.000000000000000 -0.049815118005748
-0.033286051232919 -0.019217710639585 -0.037674248456914
-0.045779044607711 -0.026430543727506 -0.023070469960026
-0.051867788406975 -0.029945881599038 -0.006019348683662
-0.050596024278383 -0.029211628237049 0.011925597289441
-0.042339044284962 -0.024444458615154 0.028226029523308
-0.027273140887785 -0.015746155233209 0.041989747288558
-0.000000000000000 -0.000000000000000 -0.049815118005748
-0.018496134334071 -0.032036244410230 -0.036259675955309
-0.024429654459698 -0.042313402735548 -0.021323950621558
-0.026908703737555 -0.046607242039264 -0.005408852963170
-0.026418888079279 -0.045758856432786 0.010785465894322
-0.022894621383867 -0.039654647456911 0.026436431637941
-0.015355646960057 -0.026596760717909 0.040948391893486
-0.000000000000000 -0.000000000000000 -0.049815118005748
-0.000000000000000 -0.036309017710339 -0.035589956059286
-0.000000000000000 -0.047273292454049 -0.020631756287663
-0.000000000000000 -0.051675786366447 -0.005193611943154
-0.000000000000000 -0.050815730690458 0.010372717591526
-0.000000000000000 -0.044489633172666 0.025686101688387
-0.000000000000000 -0.030316588229639 0.040422117639519
0.000000000000000 -0.000000000000000 -0.049815118005748
0.018422854617625 -0.031909320218181 -0.036116018976805
0.024307976693871 -0.042102650662984 -0.021217741560168
0.026764953958725 -0.046358260118753 -0.005379958170438
0.026279549165091 -0.045517514353942 0.010728581020809
0.022786184948649 -0.039466830041721 0.026311220027814
0.015304154209252 -0.026507572657293 0.040811077891338
0.000000000000000 -0.000000000000000 -0.049815118005748
0.033152869816836 -0.019140818313159 -0.037523509346281
0.045829649529645 -0.026459760492807 -0.023095972443560
0.052288905121942 -0.030189013447784 -0.006068220024078
0.050910857853398 -0.029393397486334 0.011999804274721
0.042289602909023 -0.024415913623447 0.028193068606016
0.027154245218747 -0.015677510786684 0.041806695431158
0.000000000000000 -0.000000000000000 -0.049815118005748
0.039186360495468 -0.000000000000000 -0.038410316117142
0.056803651667469 -0.000000000000000 -0.024791146049150
0.072097497329379 -0.000000000000000 -0.007246071120158
0.067060501396178 -0.000000000000000 0.013688667526320
0.051379603016815 -0.000000000000000 0.029664027632614
0.031789354260577 -0.000000000000000 0.042385805680769
非常感谢您提供的任何帮助。
最佳答案
other answer也适用于此,因为您已经有一个(常规!)网格。但是,采用唯一值对您的数据不起作用(显然)。相反,我查看了数据并手动决定了网格的形状,即在我们返回 x=0
之前,在 x 数据中总是有 7 个条目。所以以下工作:
data = np.loadtxt('lobe1.dat')
xs = data[:,0].reshape((-1, 7))
ys = data[:,1].reshape((-1, 7))
zs = data[:,2].reshape((-1, 7))
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(xs,ys,zs, rstride=1, cstride=1,color='b')
plt.show()
证明:
关于python - 绘制到 plot_surface - 无法将数据正确转换为所需格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29705225/
初学者 android 问题。好的,我已经成功写入文件。例如。 //获取文件名 String filename = getResources().getString(R.string.filename
我已经将相同的图像保存到/data/data/mypackage/img/中,现在我想显示这个全屏,我曾尝试使用 ACTION_VIEW 来显示 android 标准程序,但它不是从/data/dat
我正在使用Xcode 9,Swift 4。 我正在尝试使用以下代码从URL在ImageView中显示图像: func getImageFromUrl(sourceUrl: String) -> UII
我的 Ubuntu 安装 genymotion 有问题。主要是我无法调试我的数据库,因为通过 eclipse 中的 DBMS 和 shell 中的 adb 我无法查看/data/文件夹的内容。没有显示
我正在尝试用 PHP 发布一些 JSON 数据。但是出了点问题。 这是我的 html -- {% for x in sets %}
我观察到两种方法的结果不同。为什么是这样?我知道 lm 上发生了什么,但无法弄清楚 tslm 上发生了什么。 > library(forecast) > set.seed(2) > tts lm(t
我不确定为什么会这样!我有一个由 spring data elasticsearch 和 spring data jpa 使用的类,但是当我尝试运行我的应用程序时出现错误。 Error creatin
在 this vega 图表,如果我下载并转换 flare-dependencies.json使用以下 jq 到 csv命令, jq -r '(map(keys) | add | unique) as
我正在提交一个项目,我必须在其中创建一个带有表的 mysql 数据库。一切都在我这边进行,所以我只想检查如何将我所有的压缩文件发送给使用不同计算机的人。基本上,我如何为另一台计算机创建我的数据库文件,
我有一个应用程序可以将文本文件写入内部存储。我想仔细看看我的电脑。 我运行了 Toast.makeText 来显示路径,它说:/数据/数据/我的包 但是当我转到 Android Studio 的 An
我喜欢使用 Genymotion 模拟器以如此出色的速度加载 Android。它有非常好的速度,但仍然有一些不稳定的性能。 如何从 Eclipse 中的文件资源管理器访问 Genymotion 模拟器
我需要更改 Silverlight 中文本框的格式。数据通过 MVVM 绑定(bind)。 例如,有一个 int 属性,我将 1 添加到 setter 中的值并调用 OnPropertyChanged
我想向 Youtube Data API 提出请求,但我不需要访问任何用户信息。我只想浏览公共(public)视频并根据搜索词显示视频。 我可以在未经授权的情况下这样做吗? 最佳答案 YouTube
我已经设置了一个 Twilio 应用程序,我想向人们发送更新,但我不想回复单个文本。我只是想让他们在有问题时打电话。我一切正常,但我想在发送文本时显示传入文本,以确保我不会错过任何问题。我正在使用 p
我有一个带有表单的网站(目前它是纯 HTML,但我们正在切换到 JQuery)。流程是这样的: 接受用户的输入 --- 5 个整数 通过 REST 调用网络服务 在服务器端运行一些计算...并生成一个
假设我们有一个名为 configuration.js 的文件,当我们查看内部时,我们会看到: 'use strict'; var profile = { "project": "%Projec
这部分是对 Previous Question 的扩展我的: 我现在可以从我的 CI Controller 成功返回 JSON 数据,它返回: {"results":[{"id":"1","Sourc
有什么有效的方法可以删除 ios 中 CBL 的所有文档存储?我对此有疑问,或者,如果有人知道如何从本质上使该应用程序像刚刚安装一样,那也会非常有帮助。我们正在努力确保我们的注销实际上将应用程序设置为
我有一个 Rails 应用程序,它与其他 Rails 应用程序通信以进行数据插入。我使用 jQuery $.post 方法进行数据插入。对于插入,我的其他 Rails 应用程序显示 200 OK。但在
我正在为服务于发布请求的 API 调用运行单元测试。我正在传递请求正文,并且必须将响应作为帐户数据返回。但我只收到断言错误 注意:数据是从 Azure 中获取的 spec.js const accou
我是一名优秀的程序员,十分优秀!