- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如标题所示,我正在研究时间序列对齐,并且需要对齐结果的可视化。
为此,我想绘制连接对齐算法生成的“ anchor ”的线。
np.random.seed(5)
x = np.random.rand(10) # time-series 1
y = np.random.rand(20) # time-series 2
ap = np.array(([0, 4, 9], # the anchor points
[0, 9, 19]))
fig = plt.figure(figsize=(10,5))
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
ax1.plot(x, 'r')
ax2.plot(y, 'g')
示例中的 anchor ap
指定两个时间序列x
的指数之间的一对一“映射” y
,即x[0]
对应y[0]
; x[4]
到 y[9]
;以及 x[9]
到 y[19]
。目标是在两个单独的图之间绘制线条以显示对齐结果。
最佳答案
要连接 matplotlib 中的两个子图,您可以使用 ConnectionPatch
。
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import ConnectionPatch
np.random.seed(5)
x = np.random.rand(21) # time-series 1
y = np.random.rand(21) # time-series 2
ap = np.array(([0, 5, 10], # the anchor points
[0,10, 20]))
fig = plt.figure(figsize=(10,5))
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
ax1.plot(x, 'r')
ax2.plot(y, 'g')
ls = ["-","--"]
c = ["gold", "blue"]
for i, row in enumerate(ap):
for j, ind in enumerate(row):
px = (ind, x[ind])
py = (ind, y[ind])
con = ConnectionPatch(py,px, coordsA="data", coordsB="data",
axesA=ax2, axesB=ax1, linestyle=ls[i], color=c[i])
ax2.add_artist(con)
plt.show()
关于python - 在两个单独的一维图之间绘制连接点的线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44045344/
我有以下情节 require(ggplot2) dtf <- structure(list(Variance = c(5.213, 1.377, 0.858, 0.613, 0.412, 0.229,
我可以捕获算术中定义的连接点吗? 类似于: int a = 4; int b = 2; int c = a + b; 我可以创建一个切入点来捕获这些行中的任何一行吗?我可以获得什么背景信息? 我想添加
我编写了以下代码,用于使用鼠标事件添加和删除点或圆。下一步是在创建它们时用一条线将它们连接起来(创建一个多边形)。我完全卡住了,不知道从哪里开始。我正在寻找文档,但如果有人能指出正确的方向,我将不胜感
我读过 Evans、Nilsson 和 McCarthy 等书,了解领域驱动设计背后的概念和推理;但是,我发现很难将所有这些放在一个真实世界的应用程序中。缺乏完整的例子让我摸不着头脑。我找到了很多框架
有没有办法在 Python 中创建 NTFS 连接点?我知道我可以调用 junction 实用程序,但最好不要依赖外部工具。 最佳答案 自 Python 3.5 以来,_winapi 模块中有一个函数
Swing (Java 1.6.0_u25) 中的 JFileChooser 似乎不知道如何处理 NTFS 连接点或符号链接(symbolic link)。 文件选择器没有特殊处理: int rv =
这个问题在这里已经有了答案: Check if a file is real or a symbolic link (9 个回答) 关闭 5 年前。 有谁知道如何检查文件或目录是否是符号链接(sym
我是一名优秀的程序员,十分优秀!