I try to draw clouds of coloured dots. The coordinates of the points are given by a formula. Let's say they're randomly distributed in [0,1]: that doesn't really matter here and isn't the problem.
For the plot, I use the following code. It's remarkably slow (in the sense that I didn't expect it to take so long).
The options don't seem to be the cause of the slowdown (*), but they do limit my use of list_plot, which seems to be much more efficient.
For example, with the following code:
- the total CPU time for Trace() is 1min
- the total CPU time for Trace2() is 121ms
I'm looking for ideas on how to improve the time it takes to draw my colored dots (I'd probably have to find a suitable python library, but I'm far from an expert...).
N = 10^4
R = range(N)
P=[(randrange(N)/N*1.0,randrange(N)/N*1.0) for k in R]
#..................
def mycolorscale(k):
return Color(1 - k/N, 0, 0)
#..................
def Trace():
g=Graphics()
k=0
for p in P:
g+=point(p,rgbcolor=mycolorscale(k),size=1)
k+=1
g.show()
#..................
def Trace2():
list_plot(P,plotjoined=False,size=1).show()
(*) Replacing
g+=point(p,rgbcolor=mycolorscale(k),size=1)
by
g+=point(p)
in the Trace code changes essentially nothing to the duration.