我在QWidget
中嵌入了条形图。当我的GUI的窗口大小最大时,图表看起来很棒(见图1)但是当我减小窗口的大小时,滴答标签几乎消失(见图2)。
如何保留标签,如何避免标签重叠?
这是我的代码:
class Graph_init(FigureCanvas):
def __init__(self, parent=None):
self.fig = Figure()
self.fig.patch.set_facecolor("None")
self.axes = self.fig.add_subplot(111)
self.fig.tight_layout()
self.compute_initial_figure()
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
class Graph_populate(Graph_init):
def compute_initial_figure(self):
n=3
label = ['','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre']
x1 = [0.7,1.7,2.7,3.7,4.7,5.7,6.7,7.7,8.7,9.7,10.7,11.7]
x2 = [1,2,3,4,5,6,7,8,9,10,11,12]
x3 = [1.3,2.3,3.3,4.3,5.3,6.3,7.3,8.3,9.3,10.3,11.3,12.3]
y1 = [15,25,35,45,55,65,75,85,95,105,115,125]
y2 = [10,20,30,40,50,60,70,80,90,100,110,120]
y3 = [20,30,40,50,60,70,80,90,100,110,120,130]
self.axes.bar(x1,y1,width=0.80/n)
self.axes.bar(x2,y2,width=0.80/n)
self.axes.bar(x3,y3,width=0.80/n)
self.axes.set_xticks(np.arange(13))
self.axes.set_xticklabels(label)
self.axes.patch.set_facecolor('None')
谢谢