如何从matplotlib ginput切片列表?

2024-09-28 01:26:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Python中有一个值列表,我正在用matplotlib绘制这些值。然后,我尝试使用matplotlib中的ginput来单击图形上的两个点,从这两个点开始X坐标,在这两个点之间分割我的原始列表。然而,我似乎找不到一个办法来做这件事。在

我已经有一个名为MIList的号码列表,以下代码对我无效:

startinput = plt.ginput(2)
print("clicked", startinput)
startinputxvalues = [x[0] for x in startinput]
print(startinputxvalues)
x1 = startinputxvalues[0]
print(x1)
x2 = startinputxvalues[1]
print(x2)
slicedMIList = [MIList[int(x1):int(x2)]]
plt.plot(slicedMIList)

这给了我一个数组,但是它没有在我的图上画出这些值-有人知道我做错了什么吗?在

谢谢


Tags: 图形列表matplotlib绘制pltintprintx1

热门问题