# ########################################################################## # Dessine une image surfacique pixel par pixel dans une fenêtre Matplotlib # # Programme réalisé le 01 novembre 2022 par Jean-Christophe MICHEL # # www.gecif.net # # ########################################################################## import matplotlib.pyplot as plt from math import * x_min=-40 x_max=40 y_min=-40 y_max=40 # résolution de l'image : res_x=500 res_y=500 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=x*cos(x)+y*sin(y) ligne.append(n) tab.append(ligne) # crée une figure dans la fenêtre fig=plt.figure(1, figsize=(8, 8)) # 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) plt.show()