I'm trying to make a graph using matplotlib and plot it directly in a Qlabel using Qpixmap. However, the error QPixmap () is happening: argument 1 has unexpected type 'Figure'. How do I display the graph without saving it before?
import matplotlib.pyplot as plt
import numpy as np
labels = ['Word', 'Excel', 'Chrome','Visual Studio Code']
title = [20,32,22,25]
cores = ['lightblue','green','blue','red']
explode = (0,0.1,0,0)
plt.rcParams['font.size'] = '16'
total=sum(title)
plt.pie(title,explode=explode,labels=labels,colors=cores,autopct=lambda p: '{:.0f}'.format(p*total/100), shadow=True, startangle=90)
plt.axis('equal')
grafic = plt.gcf()
self.ui.grafig_1.setPixmap(QPixmap(grafic))