You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在(time, velocity)图中高亮filteredvel中低于14.0的数值?

问题解决:绘制(time, velocity)曲线并高亮低速度区域

需求与问题说明

  • 需求:绘制(time, velocity)曲线图,筛选出速度值低于14.0的部分并在图中高亮
  • 当前代码问题:仅绘制了fixations的0/1布尔值,未展示实际的滤波后速度曲线,也未实现目标区域高亮

修改后的代码

# IV-T
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal as flt  # 确保导入依赖库

diffhor = np.diff(xframe)
diffvert = np.diff(yframe)
vel = np.sqrt((diffhor**2)+(diffvert**2))

filteredvel = flt.savgol_filter(vel, 70, 2)

fixations = np.zeros_like(filteredvel, dtype=bool)
fixations[filteredvel <= 14.0] = True

# 匹配速度数据的时间轴(np.diff后数据长度减1)
time_axis = timeframe[0:-1]

# 绘制完整的滤波后速度曲线
plt.plot(time_axis, filteredvel, label='Filtered Velocity', color='blue')

# 高亮速度≤14.0的区域
plt.scatter(time_axis[fixations], filteredvel[fixations], color='red', s=5, label='Velocity ≤14.0')

# 配置图表标签与样式
plt.xlabel('time (ms)')
plt.ylabel('velocity')
plt.title('IV-T: Velocity over Time with Low-Speed Highlight')
plt.legend()
plt.show()

关键修改说明

  • 先绘制完整的滤波速度曲线,用蓝色实线呈现整体变化趋势
  • 通过布尔索引fixations筛选出低速度数据点,用红色散点高亮,s=5控制散点大小避免遮挡主曲线
  • 添加图例区分不同元素,提升图表可读性

内容的提问来源于stack exchange,提问作者jelmer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 14:12:38