Mis a jour le 2024-03-17, 13:3

Dessin sous matplotlib

Dessin de lignes sous matplotlib :
Exemple de dessin avec des lignes : import math pyplot.figure(figsize = (8, 8)) axes = pyplot.gca() for theta in range(0, 180, 10): thetaRad = theta * math.pi / 180 x1 = math.cos(thetaRad) y1 = math.sin(thetaRad) x2 = - math.cos(thetaRad) y2 = - math.sin(thetaRad) axes.add_artist(matplotlib.lines.Line2D((x1, x2), (y1, y2), color = 'red', linewidth = 5, linestyle = 'dotted', marker = 'D', markeredgecolor = 'cyan', markeredgewidth = 3, markerfacecolor = 'yellow', markersize = 15)) axes.set_xlim(-1, 1) axes.set_ylim(-1, 1)
Dessin de rectangles sous matplotlib :
Dessin de cercles sous matplotlib :
Dessin d'ellipses sous matplotlib :
Dessin d'arcs sous matplotlib :
Exemple de dessin : from matplotlib import patches figure = pyplot.figure(figsize = (10, 10)) # suppression des marges pyplot.gcf().subplots_adjust(0, 0, 1, 1) axes = figure.add_subplot(111) # pas de cadre axes.set_frame_on(False) # pas de graduations d'axes axes.xaxis.set_visible(False) axes.yaxis.set_visible(False) axes.add_artist( patches.Rectangle((0.2, 0.2), 0.4, 0.3, edgecolor = 'black', facecolor = 'orange', fill = True, hatch = '/', linestyle = 'dashed', linewidth = 3, zorder = 1)) axes.add_artist( patches.Rectangle((0.4, 0.4), 0.5, 0.2, edgecolor = 'black', facecolor = 'pink', fill = True, hatch = '|', linestyle = 'dashdot', linewidth = 3, alpha = 0.7, zorder = 3)) axes.add_artist( patches.Circle((0.5, 0.6), 0.15, color = 'cyan', zorder = 2)) axes.add_artist( patches.Ellipse((0.2, 0.7), 0.3, 0.2, 45, edgecolor = 'magenta', facecolor = 'yellow', zorder = 2)) axes.add_artist( patches.Arc((0.7, 0.7), 0.3, 0.2, 20, 0, 120, color = 'red', linewidth = 5))

Copyright python-simple.com
programmer en python, tutoriel python, graphes en python, Aymeric Duclert