def _add_mean_indicator(self, g, line, bins, probs, pid): # maxp = max(probs) wm, we, mswd, valid_mswd = self._calculate_stats( self.xs, self.xes, bins, probs) #ym = maxp * percentH + offset #set ym in screen space #convert to data space ogid = self.group_id gid = ogid + 1 # sgid = ogid * 2 text = '' if self.options.display_mean: text = self._build_label_text(wm, we, mswd, valid_mswd, len(self.xs)) m = MeanIndicatorOverlay(component=line, x=wm, y=20 * gid, error=we, nsgima=self.options.nsigma, color=line.color, text=text, visible=self.options.display_mean_indicator) line.overlays.append(m) line.tools.append(OverlayMoveTool(component=m, constrain='x')) m.on_trait_change(self._handle_overlay_move, 'altered_screen_point') return m
def _add_mean_indicator(self, g, line, po, bins, probs, pid): wm, we, mswd, valid_mswd = self._calculate_stats(bins, probs) ogid = self.group_id gid = ogid + 1 text = '' if self.options.display_mean: n = self.xs.shape[0] mswd_args = (mswd, valid_mswd, n) text = self._build_label_text( wm, we, n, mswd_args=mswd_args, sig_figs=self.options.mean_sig_figs, percent_error=self.options.display_percent_error) group = self.options.get_group(self.group_id) color = group.color m = MeanIndicatorOverlay(component=line, x=wm, y=20 * gid, error=we, nsgima=self.options.nsigma, color=color, visible=self.options.display_mean_indicator, id='mean_{}'.format(self.group_id)) font = self.options.get_formatting_value('label_font', 'mean_indicator_font') m.font = font m.text = text line.overlays.append(m) line.tools.append(OverlayMoveTool(component=m, constrain='x')) m.on_trait_change(self._handle_overlay_move, 'altered_screen_point') if m.id in po.overlay_positions: ap = po.overlay_positions[m.id] m.y = ap[1] if m.label: m.label.on_trait_change(self._handle_label_move, 'altered_screen_point') if m.label.id in po.overlay_positions: ap = po.overlay_positions[m.label.id] m.label.altered_screen_point = (ap[0], ap[1]) m.label.trait_set(x=ap[0], y=ap[1]) return m