小编geo*_*rge的帖子

加速matplotlib散点图

我正在尝试制作一个主要使用matplotlib的交互式程序来制作相当多点(10k-100k左右)的散点图.现在它可以工作,但更改需要很长时间才能呈现.少量积分是可以的,但一旦数量上升,匆忙就会令人沮丧.所以,我正在研究加速分散的方法,但我没有太多运气

有一种显而易见的方法(现在实现它的方式)(我意识到绘图重绘没有更新.我不想改变fps结果大量调用随机).

import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
import time


X = np.random.randn(10000)  #x pos
Y = np.random.randn(10000)  #y pos
C = np.random.random(10000) #will be color
S = (1+np.random.randn(10000)**2)*3 #size

#build the colors from a color map
colors = mpl.cm.jet(C)
#there are easier ways to do static alpha, but this allows 
#per point alpha later on.
colors[:,3] = 0.1

fig, ax = plt.subplots()

fig.show()
background = fig.canvas.copy_from_bbox(ax.bbox)

#this makes the base collection
coll = …
Run Code Online (Sandbox Code Playgroud)

python scatter matplotlib

8
推荐指数
2
解决办法
5675
查看次数

标签 统计

matplotlib ×1

python ×1

scatter ×1