Single pixel marks in a scatter_plot

asked 2014-08-31 15:42:47 +0200

MvG gravatar image

I'd like to create a scatter plot of some data and ensure that every data point colors exactly one pixel of the result, its position simply rounded to nearest neighbor without any antialiasing. However, the marker="," setting in the scatter_plot invocation doesn't have the effect the manual description “(pixel)” suggests. Is there some additional setting required to achieve this, or perhaps some other approach altogether?

Example (related to this post about how to recreate this image):

import itertools
def genpos(limit = 100):
    r = range(limit)
    for m in r:
        dm = m*m
        if dm > limit: break
        for n in r:
            dn = dm + n*n
            if dn > limit: break
            for p in r:
                dp = dn + p*p
                if dp > limit: break
                for q in r:
                    d = dp + q*q
                    if d > limit: break
                    if d == 0: continue
                    abc = [m*m + n*n - p*p - q*q, 2*(m*q + n*p), 2*(n*q - m*p)]
                    abc = map(abs, abc)
                    for i in itertools.permutations(abc, 2):
                        yield (i[0]/d, i[1]/d)
scatter_plot(list(genpos(100)), markersize=1, marker=",", aspect_ratio=1)
edit retag flag offensive close merge delete