Thanks also to Vincent Lacroix with the "only" PIL solution.
*Christophe BAL* *Enseignant de mathématiques en Lycée **et développeur Python amateur* *---* *French math teacher in a "Lycée" **and amateur developer in Python* 2014-11-27 23:10 GMT+01:00 Christophe Bal <[email protected]>: > The solution of Volker Braun does the job in a very Sage way. I like that > a lot ! Thanks. > > ---------------------------------------------------- > nmax = 150 > m = matrix(nmax, nmax, lambda i, j: binomial(i,j)%2) > m.plot() > > > *Christophe BAL* > *Enseignant de mathématiques en Lycée* > *et développeur Python amateur* > > 2014-11-27 22:32 GMT+01:00 Volker Braun <[email protected]>: > >> Not exactly the same but shows the gist: >> >> sage: m = matrix(5, 5, lambda i, j: binomial(i,j)) >> sage: m.plot() >> >> >> >> On Thursday, November 27, 2014 9:08:30 PM UTC, projetmbc wrote: >>> >>> Hello. >>> >>> Is it possible to do the same thing as the following code in "pure" Sage >>> coding ? >>> >>> *Christophe BAL* >>> *Enseignant de mathématiques en Lycée* >>> *et développeur Python amateur* >>> >>> *--**------**------**--- **CODE **---**------**------**--* >>> *import matplotlib.pyplot as plt* >>> *import numpy as np* >>> *from sympy import binomial* >>> >>> *nmax = 200* >>> >>> *im = np.zeros((nmax+1, nmax+1, 3))* >>> >>> *for n in range(nmax):* >>> * for k in range(n+1):* >>> * if binomial(n, k) % 2 == 1:* >>> * im[k, n] = (255, 255, 255)* >>> >>> *im = im.astype(np.uint8)* >>> >>> *plt.imshow(im)* >>> *plt.axis('off')* >>> *plt.show()* >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "sage-support" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/sage-support. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
