Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making the marker size as small as possible with matplotlib.pyplot

My program can generate up to 2000000 points within 5 seconds, so I don't have a problem with speed. Right now I am using matplotlib.pyplot.scatter to scatter all my points on my graph. For s=1, it gives me small circles, but not small enough, because it does not show the intricate patterns. When I use s=0.1, it gives me this weird marker shape:

enter image description here

Which makes the marker larger despite me making the size smaller. I have searched all over the internet including stack overflow, but they do not tell how to minimize the size further. Unfortunately, I have to show all the points, and cannot just show a random sample of them.

I have come to the conclusion that matplotlib is made for a small sample of points and not meant for plotting millions of points. However, if it is possible to make the size smaller please let me know.

Anyway, for my points, I have all the x values in order in one array, and all the y values in order in another array. Could someone suggest a graphing package in python I could use to graph all the points in a way that the size would be very small since when I plot the points now it just becomes one big block of color instead of intricate designs forming in the shape as they should be.

Thanks for any help in advance!


EDIT: My code that I am using to scatter the points is:

plt.savefig(rootDir+"b"+str(Nvertices)+"_"+str(xscale)+"_"+str(yscale)+"_"+str(phi)+"_"+str(psi)+"_"+CurrentRun+"_color.png", dpi =600)

EDIT: I got my answer, I added linewidths = 0 and that significantly reduced the size of the points, giving me what I needed.

like image 265
Mike Smith Avatar asked Jan 26 '23 08:01

Mike Smith


1 Answers

Perhaps you can try making the linewidths as 0 i.e., the line width of the marker edges. Notice the difference in the two plots below

fig, ax = plt.subplots(figsize=(6, 4))
plt.scatter(np.random.rand(100000), np.random.rand(100000), s=0.1)

enter image description here

fig, ax = plt.subplots(figsize=(6, 4))
plt.scatter(np.random.rand(100000), np.random.rand(100000), s=0.1, linewidths=0)

enter image description here

like image 181
Sheldore Avatar answered Apr 28 '23 03:04

Sheldore