@@ -91,6 +91,18 @@ class LinePlotStyle:
9191 MEAN_DARK_FACTOR = 110
9292
9393
94+ class LinePlotAxisItem (pg .AxisItem ):
95+ def __init__ (self , * args , ** kwargs ):
96+ super ().__init__ (* args , ** kwargs )
97+ self ._ticks = {}
98+
99+ def set_ticks (self , ticks ):
100+ self ._ticks = dict (enumerate (ticks , 1 )) if ticks else {}
101+
102+ def tickStrings (self , values , scale , spacing ):
103+ return [self ._ticks .get (v * scale , "" ) for v in values ]
104+
105+
94106class LinePlotViewBox (ViewBox ):
95107 selection_changed = Signal (np .ndarray )
96108
@@ -172,8 +184,10 @@ def reset(self):
172184
173185class LinePlotGraph (pg .PlotWidget ):
174186 def __init__ (self , parent ):
187+ self .bottom_axis = LinePlotAxisItem (orientation = "bottom" )
175188 super ().__init__ (parent , viewBox = LinePlotViewBox (),
176- background = "w" , enableMenu = False )
189+ background = "w" , enableMenu = False ,
190+ axisItems = {"bottom" : self .bottom_axis })
177191 self .view_box = self .getViewBox ()
178192 self .selection = set ()
179193 self .legend = self ._create_legend (((1 , 0 ), (1 , 0 )))
@@ -213,7 +227,7 @@ def reset(self):
213227 self .selection = set ()
214228 self .view_box .reset ()
215229 self .clear ()
216- self .getAxis ('bottom' ).setTicks (None )
230+ self .getAxis ('bottom' ).set_ticks (None )
217231 self .legend .hide ()
218232
219233 def select_button_clicked (self ):
@@ -593,8 +607,8 @@ def setup_plot(self):
593607 if self .data is None :
594608 return
595609
596- ticks = [[( i , a .name ) for i , a in enumerate ( self .graph_variables , 1 )] ]
597- self .graph .getAxis (' bottom' ). setTicks (ticks )
610+ ticks = [a .name for a in self .graph_variables ]
611+ self .graph .getAxis (" bottom" ). set_ticks (ticks )
598612 self .plot_groups ()
599613 self .apply_selection ()
600614 self .graph .view_box .enableAutoRange ()
0 commit comments