@@ -276,7 +276,7 @@ def _set_range_feat_state(self, feat, fmin=None, fmax=None):
276276 else :
277277 self .setEnabled (True )
278278 if feat is not None :
279- lim = self .pipeline .get_min_max (
279+ lim = self .pipeline .get_min_max_coarse (
280280 feat = feat , plot_id = self .current_plot .identifier )
281281 if not (np .isinf (lim [0 ]) or np .isinf (lim [1 ])):
282282 self .widget_range_feat .setLimits (vmin = lim [0 ], vmax = lim [1 ])
@@ -307,16 +307,19 @@ def _set_range_xy_state(self, axis_x=None, range_x=None,
307307 [self .widget_range_x , self .widget_range_y ],
308308 ):
309309 if axis is not None :
310- lim = self .pipeline .get_min_max (feat = axis , plot_id = plot_id )
310+ lim = self .pipeline .get_min_max_coarse (
311+ feat = axis ,
312+ plot_id = plot_id )
311313 if not (np .isinf (lim [0 ]) or np .isinf (lim [1 ])):
312314 rc .blockSignals (True )
313315 rc .setLimits (vmin = lim [0 ],
314316 vmax = lim [1 ])
315317 if rang is None or rang [0 ] == rang [1 ]:
316318 # default range is limits + 5% margin
317- rang = self .pipeline .get_min_max (feat = axis ,
318- plot_id = plot_id ,
319- margin = 0.05 )
319+ rang = self .pipeline .get_min_max_coarse (
320+ feat = axis ,
321+ plot_id = plot_id ,
322+ margin = 0.05 )
320323 rc .write_pipeline_state ({"active" : True ,
321324 "start" : rang [0 ],
322325 "end" : rang [1 ],
@@ -347,12 +350,9 @@ def _set_kde_spacing(self, spacing_x=None, spacing_y=None):
347350 spinBox .setSingleStep (10 ** (- dec + 1 ))
348351 spinBox .setValue (spacing )
349352
350- def _set_kde_spacing_auto (self , axis_x = None , axis_y = None ):
353+ def _set_kde_spacing_simple (self , axis_x = None , axis_y = None ):
351354 """automatically estimate and set the KDE spacing
352355
353- - uses :func:`dclab.kde.binning.bin_width_percentile`
354- - uses _set_kde_spacing
355-
356356 Not to be confused with `on_spacing_auto`!
357357 """
358358 if len (self .pipeline .slots ) == 0 :
@@ -361,32 +361,28 @@ def _set_kde_spacing_auto(self, axis_x=None, axis_y=None):
361361 return
362362 else :
363363 self .setEnabled (True )
364- dslist , _ = self .pipeline .get_plot_datasets (
365- self .current_plot .identifier )
366- if dslist :
367- spacings_xy = []
368- for axis , scaleCombo in zip ([axis_x , axis_y ],
369- [self .comboBox_scale_x ,
370- self .comboBox_scale_y ]):
371- if axis is None :
372- # nothing to do
373- spacings_xy .append (None )
374- else :
375- # determine good approximation
376- spacings = []
377- for ds in dslist :
378- spa = ds .get_kde_spacing (
379- a = ds [axis ],
380- feat = axis ,
381- scale = scaleCombo .currentData (),
382- method = dclab .kde .binning .bin_width_percentile ,
383- )
384- spacings .append (spa )
385- spacings_xy .append (np .min (spacings ))
386- spacing_x , spacing_y = spacings_xy
387- # sets the limits before setting the value
388- self ._set_kde_spacing (spacing_x = spacing_x ,
389- spacing_y = spacing_y )
364+
365+ spacings_xy = []
366+ for feat , scaleCombo in zip ([axis_x , axis_y ],
367+ [self .comboBox_scale_x ,
368+ self .comboBox_scale_y ]):
369+ if feat is None :
370+ spacings_xy .append (None )
371+ else :
372+ vmin , vmax = self .pipeline .get_min_max_coarse (
373+ feat = feat ,
374+ plot_id = self .current_plot .identifier )
375+
376+ if scaleCombo .currentData () == "log" :
377+ vmin = np .log (vmin )
378+ vmax = np .log (vmax )
379+
380+ spacings_xy .append ((vmax - vmin )/ 300 )
381+
382+ spacing_x , spacing_y = spacings_xy
383+ # sets the limits before setting the value
384+ self ._set_kde_spacing (spacing_x = spacing_x ,
385+ spacing_y = spacing_y )
390386
391387 @property
392388 def current_plot (self ):
@@ -432,14 +428,14 @@ def on_axis_changed(self):
432428 gen = self .read_plot_state ()["general" ]
433429 if self .sender () == self .comboBox_axis_x :
434430 self ._set_range_xy_state (axis_x = gen ["axis x" ])
435- self ._set_kde_spacing_auto (axis_x = gen ["axis x" ])
431+ self ._set_kde_spacing_simple (axis_x = gen ["axis x" ])
436432 elif self .sender () == self .comboBox_axis_y :
437433 self ._set_range_xy_state (axis_y = gen ["axis y" ])
438- self ._set_kde_spacing_auto (axis_y = gen ["axis y" ])
434+ self ._set_kde_spacing_simple (axis_y = gen ["axis y" ])
439435 elif self .sender () == self .comboBox_scale_x :
440- self ._set_kde_spacing_auto (axis_x = gen ["axis x" ])
436+ self ._set_kde_spacing_simple (axis_x = gen ["axis x" ])
441437 elif self .sender () == self .comboBox_scale_y :
442- self ._set_kde_spacing_auto (axis_y = gen ["axis y" ])
438+ self ._set_kde_spacing_simple (axis_y = gen ["axis y" ])
443439
444440 @QtCore .pyqtSlot ()
445441 def on_column_num_changed (self ):
0 commit comments