# ########################################################################## # Dessine une image surfacique pixel par pixel dans une fenêtre Matplotlib # # Programme réalisé le 06 novembre 2022 par Jean-Christophe MICHEL # # www.gecif.net # # ########################################################################## import matplotlib.pyplot as plt from math import * coeff_zoom=2 x_min=-4.44350838253174E+0001*coeff_zoom x_max=4.31538338253302E+0001*coeff_zoom y_min=-3.29278753690077E+0001*coeff_zoom y_max=3.27638128689780E+0001*coeff_zoom # résolution de l'image : res_x=800 res_y=600 tab = [] for py in range(1,res_y+1): ligne=[] for px in range(1,res_x+1): x=x_min+px*(x_max-x_min)/res_x y=y_max-py*(y_max-y_min)/res_y # pour modifier l'image il suffit de changer l'équation de n en fonction de x et de y : n=int(x*cos(y)+y*sin(x)) % 100 ligne.append(n) tab.append(ligne) # crée une figure dans la fenêtre fig=plt.figure(1, figsize=(8, 6)) # crée un axe dans la figure : ax=fig.add_subplot(1,1,1) # n'affiche pas les graduations sur les axes : ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) # agrandi le repère à toute la surface de la figure : plt.gcf().subplots_adjust(left = 0, bottom = 0, right = 1, top = 1, wspace = 0, hspace = 0) # affiche l'image : ax.imshow(tab, cmap='CMRmap') plt.show()