我在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)
这给了我一个数组,但是它没有在我的图上画出这些值-有人知道我做错了什么吗?在
谢谢
主要的一点是,一旦对画布进行了更改,就需要重新绘制画布。所以为了让新的情节变得可见你可以
以下是完整的工作代码:
^{pr2}$相关问题 更多 >
编程相关推荐