@@ -46,17 +46,12 @@ def __init__(self):
4646 self .ax .set_xlim (0.0 , 1.0 )
4747 self .ax .set_ylim (0.0 , 1.0 )
4848
49- font = {'family' : 'serif' ,
50- 'color' : 'darkred' ,
51- 'weight' : 'normal' ,
52- 'fontsize' : 'smaller' ,
53- }
54-
55- self .initPlot (self .nbrCategories )
49+ self .changeCategories ([])
5650 self .updateValues (np .random .rand (self .nbrCategories ))
5751
58- def initPlot (self , nbrBar :int ):
59- self .nbrCategories = nbrBar
52+ def changeCategories (self , categories :int ):
53+ self .clear ()
54+ self .nbrCategories = len (categories )
6055 if self .nbrCategories == 0 :
6156 bottom = 0
6257 top = 0
@@ -94,17 +89,26 @@ def initPlot(self, nbrBar:int):
9489 barpath , facecolor = 'green' , alpha = 0.5 ) #edgecolor='yellow',
9590 self .ax .add_patch (patch )
9691
92+ # Add category names
93+ font = {'family' : 'serif' ,
94+ 'color' : 'darkred' ,
95+ 'weight' : 'normal' ,
96+ 'fontsize' : 'large' ,
97+ }
98+
99+ for i , cat in enumerate (categories ):
100+ posy = (bottom [i ]* 2 + top [i ])/ 3.
101+ self .ax .text (0.01 , posy , cat , fontdict = font )
102+
97103 self .canvas .draw ()
98104
99105 def updateValues (self , values :np .ndarray ):
100106 self .verts [2 ::5 , 0 ] = values + self .offset_nullValue
101107 self .verts [3 ::5 , 0 ] = values + self .offset_nullValue
102108 self .canvas .draw ()
103109
104- def changeCategories (self , categories ):
105- self .initPlot (len (categories ))
106- for cat in categories :
107- self .ax .text (0.01 , 0.5 , r'$\cos(2 \pi t) \exp(-t)$' , fontdict = font )
110+ def clear (self ):
111+ self .ax .clear ()
108112
109113
110114class HandPlotWidget (QtWidgets .QWidget ):
0 commit comments