Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何防止matplotlib丢弃点?_Python_Matplotlib - Fatal编程技术网

Python 如何防止matplotlib丢弃点?

Python 如何防止matplotlib丢弃点?,python,matplotlib,Python,Matplotlib,我使用matplotlib绘制了一个相当密集的数据集(最多60000个值),通常效果非常好。但是,如果数据集包含一些异常值,则有时会删除这些异常值: [... 0, 0, 1, 0, 0, 0, 1, 172, 962, 270, 93, 39, 24, 19, 18, 12, 28, 17, 18, 11, 7, 7, 8, 6, 4, 3, 9, 5, 4, 3, 3, 3, 4, 3, 3, 2, 6, 3, 3, 3, 2, 1, 3, 2, 2, 1, 4, 3, 0, 2, 1,

我使用matplotlib绘制了一个相当密集的数据集(最多60000个值),通常效果非常好。但是,如果数据集包含一些异常值,则有时会删除这些异常值:

[... 0, 0, 1, 0, 0, 0, 1, 172, 962, 270, 93, 39, 24, 19, 18, 12, 28, 17, 18, 11,
 7, 7, 8, 6, 4, 3, 9, 5, 4, 3, 3, 3, 4, 3, 3, 2, 6, 3, 3, 3, 2, 1, 3, 2, 2, 1, 4,
 3, 0, 2, 1, 1, 1, 1, 2, 5, 2, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 3, 0, 0, 1,
 0, 1, 0, 1, 1, 3, ...] 
将导致一个平面图,没有显示接近1000的峰值。显然,这是非常不可取的。如果我切换到点而不是线,绘图可以正常工作,但这并没有那么精确,更难直观地解析

我的代码非常简单:

fig = pyplot.figure(figsize=(16, 8))
ax = fig.add_subplot(111)
ax.plot(ts, my_points) 

png_file_in_memory = cStringIO.StringIO()
backend_agg.FigureCanvasAgg(fig).print_figure(png_file_in_memory)
return png_file_in_memory

你知道为什么会发生这种情况以及如何预防吗?

你能把它做成一个可运行的例子,这样我们就可以看到结果以及到底出了什么问题吗?我的猜测是,由于分辨率限制,没有出现峰值(但这只是一个猜测)。很难说。。。这对我很有用:
a=np.random.rand(60000)
a[np.random.randint(060000,25)]=25
plt.plot(a)