【发布时间】:2017-08-07 14:06:54
【问题描述】:
我在 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)
这给了我一个数组,但它没有在我的图表上绘制这些值 - 有人对我做错了什么有任何意见吗?
谢谢
【问题讨论】:
标签: python arrays python-3.x matplotlib ginput