@@ -46,11 +46,16 @@ def get_curve_color():
4646 return colors [COLOR_INDEX ]
4747
4848
49+ PLOT_ID = 0
50+
51+
4952class BMPlot (QwtPlot ):
5053 def __init__ (self , title , xdata , ydata , style , symbol = None , * args ):
5154 super (BMPlot , self ).__init__ (* args )
52- self .setMinimumSize (200 , 200 )
53- self .setTitle (title )
55+ global PLOT_ID
56+ self .setMinimumSize (200 , 150 )
57+ PLOT_ID += 1
58+ self .setTitle ("%s (#%d)" % (title , PLOT_ID ))
5459 self .setAxisTitle (QwtPlot .xBottom , "x" )
5560 self .setAxisTitle (QwtPlot .yLeft , "y" )
5661 self .curve_nb = 0
@@ -69,11 +74,11 @@ def __init__(self, title, xdata, ydata, style, symbol=None, *args):
6974
7075
7176class BMWidget (QWidget ):
72- def __init__ (self , points , * args , ** kwargs ):
77+ def __init__ (self , nbcol , points , * args , ** kwargs ):
7378 super (BMWidget , self ).__init__ ()
7479 self .plot_nb = 0
7580 self .curve_nb = 0
76- self .setup (points , * args , ** kwargs )
81+ self .setup (nbcol , points , * args , ** kwargs )
7782
7883 def params (self , * args , ** kwargs ):
7984 if kwargs .get ("only_lines" , False ):
@@ -84,11 +89,11 @@ def params(self, *args, **kwargs):
8489 ("Dots" , None ),
8590 )
8691
87- def setup (self , points , * args , ** kwargs ):
92+ def setup (self , nbcol , points , * args , ** kwargs ):
8893 x = np .linspace (0.001 , 20.0 , int (points ))
8994 y = (np .sin (x ) / x ) * np .cos (20 * x )
9095 layout = QGridLayout ()
91- nbcol , col , row = 2 , 0 , 0
96+ col , row = 0 , 0
9297 for style , symbol in self .params (* args , ** kwargs ):
9398 plot = BMPlot (style , x , y , getattr (QwtPlotCurve , style ), symbol = symbol )
9499 layout .addWidget (plot , row , col )
@@ -102,7 +107,7 @@ def setup(self, points, *args, **kwargs):
102107 self .text .setReadOnly (True )
103108 self .text .setAlignment (Qt .AlignCenter )
104109 self .text .setText ("Rendering plot..." )
105- layout .addWidget (self .text , row + 1 , 0 , 1 , 2 )
110+ layout .addWidget (self .text , row + 1 , 0 , 1 , nbcol )
106111 self .setLayout (layout )
107112
108113
@@ -171,7 +176,7 @@ def run_benchmark(self, max_n, **kwargs):
171176 for idx in range (4 , - 1 , - 1 ):
172177 points = int (max_n / 10 ** idx )
173178 t0 = time .time ()
174- widget = BMWidget (points , ** kwargs )
179+ widget = BMWidget (2 , points , ** kwargs )
175180 title = "%d points" % points
176181 description = "%d plots with %d curves of %d points" % (
177182 widget .plot_nb ,
0 commit comments