python/matplotlib - 寄生双轴缩放
尝试绘制频谱,即速度与强度的关系,下部 x 轴 = 速度,上部双轴 = 频率
它们之间的关系(多普勒公式)为,其中
f = (1-v/c)*f_0
f 是结果频率,v 是速度,c 是光,f_0 是 v=0 时的频率,即。 v_lsr。
我试图通过查看 http://matplotlib.sourceforge.net/examples 来解决它/axes_grid/parasite_simple2.html ,我的问题解决的
pm_to_kms = 1./206265.*2300*3.085e18/3.15e7/1.e5
aux_trans = matplotlib.transforms.Affine2D().scale(pm_to_kms, 1.)
ax_pm = ax_kms.twin(aux_trans)
ax_pm.set_viewlim_mode("transform")
是,如何用我的频率函数替换 pm_to_kms ?
有人知道如何解决这个问题吗?
Trying to plot a spectrum, ie, velocity versus intensity, with lower x axis = velocity, on the upper twin axis = frequency
The relationship between them (doppler formula) is
f = (1-v/c)*f_0
where f is the resulting frequency, v the velocity, c the speed of light, and f_0 the frequency at v=0, ie. the v_lsr.
I have tried to solve it by looking at http://matplotlib.sourceforge.net/examples/axes_grid/parasite_simple2.html , where it is solved by
pm_to_kms = 1./206265.*2300*3.085e18/3.15e7/1.e5
aux_trans = matplotlib.transforms.Affine2D().scale(pm_to_kms, 1.)
ax_pm = ax_kms.twin(aux_trans)
ax_pm.set_viewlim_mode("transform")
my problem is, how do I replace the pm_to_kms with my function for frequency?
Anyone know how to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终使用的解决方案是:
这是完美的,而且更简单的解决方案。
编辑:找到了一个非常奇特的答案。
编辑2:根据@u55的评论更改了转换调用
这基本上涉及定义我们自己的转换/转换。由于具有出色的 AstroPy 单位等效性,它变得更容易理解且更具说明性。
现在会产生所需的结果:
The solution I ended up using was:
This works perfect, and much less complicated solution.
EDIT : Found a very fancy answer.
EDIT2 : Changed the transform call according to the comment by @u55
This basically involves defining our own conversion/transform. Because of the excellent AstroPy Units equivalencies, it becomes even easier to understand and more illustrative.
This now produces the desired results:
您的“线性函数”是“简单的缩放定律”(带有偏移量)。只需将
pm_to_kms
定义替换为您的函数即可。Your "linear function" is a "simple scaling law" (with an offset). Just replace the
pm_to_kms
definition with your function.