【发布时间】:2018-05-25 01:54:21
【问题描述】:
我想绘制任何部分或数据
这里是代码
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
... ...
xs = []
avg = []
for line in lines:
if len(line) > 1:
x, y1 = line.split(',')
xs.append(float(x))
avg.append(float(y1))
ax1.plot(xs, avg, label='avg')
我添加了一些代码,以便您查看变量的类型
我试过了:
ax1.plot(xs[avg>0], avg[avg>0], label='avg')
没用
im matlab 我会做一些类似的事情:
Indxs=find (ys>0)
Plot(xs(indxs),ys(indxs))
【问题讨论】:
-
你可以查看 numpy.where (docs.scipy.org/doc/numpy-1.13.0/reference/generated/…) 来找到你想要的子集的索引。
标签: python python-2.7 matplotlib