1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
...
...
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
plt.rcParams["font.family"] = "Calibri"
plt.style.use(['fast'])
plt.tight_layout()
matplotlib.use('Qt5Agg')
SMALL_SIZE = 8
MEDIUM_SIZE = 10
BIGGER_SIZE = 14
plt.rc('font', size=SMALL_SIZE) # controls default text sizes
plt.rc('axes', titlesize=BIGGER_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=MEDIUM_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
...
...
self.figure = Figure()
self.canvas = FigureCanvasQTAgg(self.figure)
self.canvas.figure = plt.figure(figsize=(8, 7), dpi=80)
self.toolbar = NavigationToolbar(self.canvas, self)
self.ui.fl_clients.addWidget(self.toolbar)
self.ui.fl_clients.addWidget(self.canvas)
self.ax1 = self.canvas.figure.add_subplot(111)
self.ax2 = self.canvas.figure.add_subplot(111)
self.ax3 = self.canvas.figure.add_subplot(111)
self.ax1.set_title('Titre graphe : ' + str(contrat))
self.ax1.set_xlabel('Date [Année - Mois]')
self.ax1.set_ylabel('Montant ')
self.ax1.plot_date(periode, phase1, '-', label="Phase1", color='r', linewidth=1, marker='^')
self.ax2.plot_date(periode, phase2, '-', label="Phase2", color='g', linewidth=1, marker='o')
self.ax3.plot_date(periode, phase3, '-', label="Phase3", color='b', linewidth=1, marker='x')
self.ax1.grid(True)
self.ax1.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), fancybox=True, shadow=False, ncol=5)
self.canvas.figure.autofmt_xdate(rotation=45)
plt.gca().spines["top"].set_alpha(0.0)
plt.gca().spines["bottom"].set_alpha(0.3)
plt.gca().spines["right"].set_alpha(0.0)
plt.gca().spines["left"].set_alpha(0.3)
self.canvas.draw()
plt.savefig('Courbe_Fature_Client ' + str(contrat), )
plt.close() |