- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个使用 matplotlib 绘制的 3D 图形。
我想让 3D 绘图以特定角度投影,但使用axis.view_init(elevation_angle, azimuthal_angle) 没有覆盖我想要的角度,这是因为 3 个维度中存在 3 个可能的旋转平面,并且您只能在 matplotlib 中指定 2 个角度。
这是一个最小的工作示例。
import numpy,matplotlib,scipy
from matplotlib import pyplot
from scipy import constants
from mpl_toolkits.mplot3d.axes3d import Axes3D
pi=scipy.constants.pi
w= numpy.arange(0,5000,1)
def lorentzian(x,center,width,time,tau):
return 1.0/((1+((x-center)/width)**2)*width*pi)*numpy.exp(-time/tau)
centers= [1000.0,2000.0,4000.0]
widths = [100.0,300.0,50.0]
taus=numpy.zeros(len(widths))
for i in xrange(0,len(widths),1):
taus[i] = 1.0/widths[i]
time = numpy.array([0,0.019,0.033])
B = numpy.zeros((3,len(w)))
for z in xrange(0,len(time),1):
a= numpy.zeros(len(w))
for i in xrange(0,len(centers),1):
a = a + lorentzian(w,centers[i],widths[i],time[z],taus[i])
B[z] = a
ThreeD_spectrum_figure = matplotlib.pyplot.figure()
ThreeD_spectrum_axis = ThreeD_spectrum_figure.add_subplot(111, projection="3d")
colour = ["purple","green","orange"]
for i in xrange(0,len(time),1):
ThreeD_spectrum_axis.plot(w, B[i],time[i],color=colour[i],linewidth=3)
ThreeD_spectrum_axis.view_init( 135,-90)
matplotlib.pyplot.show()
这将生成如下图所示的图表,我在 ms Paint 中匆忙添加了线条来显示旋转和轴。
红色表示方位角控制,绕Y轴旋转。
蓝色显示围绕 X 轴旋转的仰角。
黑色显示了我需要的旋转,它将围绕 Z 轴旋转,这是使用 axis.view_init(elevation_angle, azimuth_angle) 不可能实现的。
任何人都可以提供任何帮助或见解来帮助我实现这种轮换吗?谢谢
最佳答案
仅使用方位角即可实现绕 z 轴的旋转。
import numpy as np
import matplotlib.animation
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D
pi=np.pi
w= np.arange(0,5000,1)
def lorentzian(x,center,width,time,tau):
return 1.0/((1+((x-center)/width)**2)*width*pi)*np.exp(-time/tau)
centers= [1000.0,2000.0,4000.0]
widths = [100.0,300.0,50.0]
taus=np.zeros(len(widths))
for i in xrange(0,len(widths),1):
taus[i] = 1.0/widths[i]
time = np.array([0,0.019,0.033])
B = np.zeros((3,len(w)))
for z in xrange(0,len(time),1):
a= np.zeros(len(w))
for i in xrange(0,len(centers),1):
a = a + lorentzian(w,centers[i],widths[i],time[z],taus[i])
B[z] = a
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
colour = ["purple","green","orange"]
for i in xrange(len(time)-1,-1,-1):
ax.plot(time[i]*np.ones_like(w), w ,B[i]*np.ones_like(w),color=colour[i],linewidth=3)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
#(elev, azim)
ax.view_init(45,0)
phi = np.linspace(0, 2*np.pi)
def update(phi):
ax.view_init(45, phi*180./np.pi)
ani = matplotlib.animation.FuncAnimation(fig, update, frames=phi)
ani.save(__file__+".gif", writer='imagemagick', fps=10)
plt.show()
关于python - 控制 3D matplotlib 图中图像投影的角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207083/
对于游戏,我正在尝试计算我正在看的位置与场景中另一个对象的位置之间的角度。我通过使用以下代码获得了角度: Vec3 out_sub; Math.Subtract(pEnt->vOrigin, pLoc
我还是 Firebase 的新手。有什么方法可以使用 Firebase 性能监控从控制台自动逐屏监控我们的 Web 应用程序?我检查了文档,它说我们需要在代码中添加一些跟踪来跟踪(如果我弄错了,请纠正
我正在使用 angular-material2 的复选框。目前复选框的默认颜色为紫色。 看起来他们已将复选框的默认颜色从“主要”更改为重音。 有没有办法在不覆盖 css 的情况下获得“主要”(绿色)颜
Angular-Material 中是否有任何分页指令可与 md-list 一起使用? 这些确实有效,但不是基于 Material 设计的。 https://github.com/brantwills
所以我有一个configmap config.json { "apiUrl": "http://application.cloudapp.net/", "test": "1232" } 称为“连续部署
我可以成功对图像进行阈值处理并找到图像的边缘。我正在努力尝试的是准确地提取黑色边缘的 Angular 。 我目前正在使用黑色边缘的极端点,并使用atan2函数计算 Angular ,但是由于混叠,根据
我需要一些帮助来计算点的角度: 我需要计算从点 (0,0) 到从图像中提取的点的角度。 1 将是 0*,2 大约是 40-44* 等。 我的问题是 atan2 显示的值不正确。atan2 的当前输出是
好的,所以我有一个运动场 512x512环绕,-32变成 512对于x和 y . 现在我需要计算两个实体之间的角度,我有以下代码作为一种解决方法,它在大多数时间都有效,但有时仍然会失败: Shoote
我有一个组件,它有一个子组件。子组件有一个按钮,可以打开一个 Material 对话框。 在对话框中,我们有表单、用户名和密码以及提交按钮。当我提交时,我正在调用后端 REST api。 这在子组件中
我一直在试图找到2之间的差异,但是要减去这个就没有运气了 The primary diff erence between the two representations is that a quate
我在 Angular Material Expansion 面板中遇到了这个问题。部分分页下拉菜单被切断。如何使下拉菜单与扩展面板的末端重叠?我尝试了 z-index 但没有成功。 Material
我正在创建一个PapperSoccer项目,但是在寻找运动/线条的方向时遇到了问题。我正在使用HoughLinesP来检测行,并且效果尽可能好。 我使用ROI,在其中寻找一行,然后相应地移动它。 到目
我正在寻找修改构建函数输出的方法 ng build --prod 想添加一些引导CSS文件到index.html的head部分,更改名称index.html => index.php等 怎么做? 最佳
如何获得两个单位向量之间的 x、y 和 z 旋转值?我不能使用点积,因为它只给我一个值。我想使用旋转矩阵在每个轴上旋转,对于那些我需要每个轴上的角度差。我尝试了仅两个组件的点积,但我有点困惑。有没有一
我必须计算图像中每条可检测线的斜率(或角度)。如果可能的话,甚至可以检测直线斜率的变化。我已经执行了 2D 傅立叶并且我知道每个区域的邻域平均角度(64x64px 的集合)。我什至尝试了 Hough
我正在使用Tiled map 编辑器创建简单的平铺 map 。在我的 map 中,我有几个矩形,如果我创建一个宽度为 50、高度为 10 的矩形并将其精确旋转 90°,则保存 map 并将其加载到我的
我计算了一个三角形的角度,但我不明白为什么我得到一些锐角的负角。例如: var sin = Math.Sin(4.45); var radians = Math.Atan(sin); var
我正在开发一个机器学习项目,其中使用 TensorFlow(和 DNNRegressor)。我想预测范围在 -pi 和 pi 之间的模算术值(角度)。当我尝试“正常方式”执行此操作时,模型不是很好,因
我有一个包含 40 个旋转图像的图像。 图像索引实际上从 0. 0-39 开始。 这是将 0-39 转换为度数的代码 int image_direction = 0; //Can be 0-39 in
在 PostGIS/PostgreSQL 中,是否有一个函数可以给出给定点所在的线串的线段的角度? 最佳答案 在 PostGIS 版本 1.5.3 上 ST_Azimuth()需要两点作为输入——据我
我是一名优秀的程序员,十分优秀!