要绘制大量相似的对象,必须使用不同的matplotlib.collections类之一——唉,它们的用法有点神秘,至少在我的理解中是这样的。。。在$ cat ellipses.py
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import EllipseCollection
N = 10**5
# centres of ellipses — uniform distribution, -5<=x<5, -3<=y<3
xy = np.random.random((N,2))*np.array((5*2,3*2))-np.array((5,3))
# width, height of ellipses
w, h = np.random.random(N)/10, np.random.random(N)/10
# rotation angles, anticlockwise
a = np.random.random(N)*180-90
# we need an axes object for the correct scaling of the ellipses
fig, ax = plt.subplots()
# create the collection
ec = EllipseCollection(w, h, a,
units='x',
offsets=xy,
transOffset=ax.transData)
ax.add_collection(ec)
ax.autoscale(tight=True)
plt.savefig('el10^5.png')
我把它记在我的低端笔记本上
^{pr2}$
如您所见,当您对每个地块所需的分期付款进行折扣时,大约需要
5秒-结果是什么?在
我认为关于偏心率和角度的细节在如此密集的描述中丢失了,但是我不知道你的任务的具体细节,也不会进一步评论。在