def curve_hidden(curve): """Return True if curve is not visible""" if isinstance(curve, ErrorbarContainer): line_hidden = True if not curve[0] else (not curve[0].get_visible()) bars_hidden = errorbars_hidden(curve) return line_hidden and bars_hidden else: return not curve.get_visible()
def generate_plot_command(artist): pos_args = get_plot_command_pos_args(artist) kwargs = get_plot_command_kwargs(artist) if isinstance(artist, ErrorbarContainer) and not errorbars_hidden(artist): base_command = BASE_ERRORBAR_COMMAND else: base_command = BASE_CREATE_LINE_COMMAND arg_string = convert_args_to_string(pos_args, kwargs) return base_command.format(arg_string)
def get_plot_command_kwargs(artist): if isinstance(artist, ErrorbarContainer): # We can't hide error bars using an argument in ax.errorbar() (visible # only affects the connecting line) so use the ax.plot command if # errorbars are hidden if errorbars_hidden(artist): kwargs = _get_plot_command_kwargs_from_line2d(artist[0]) kwargs['label'] = artist.get_label() else: kwargs = _get_plot_command_kwargs_from_errorbar_container(artist) else: kwargs = _get_plot_command_kwargs_from_line2d(artist) kwargs.update(_get_mantid_specific_plot_kwargs(artist)) return _remove_kwargs_if_default(kwargs)
def relim(self, visible_only=True): Axes.relim(self, visible_only) # relim on any non-errorbar objects lower_xlim, lower_ylim = self.dataLim.get_points()[0] upper_xlim, upper_ylim = self.dataLim.get_points()[1] for container in self.containers: if isinstance(container, ErrorbarContainer) and ( (visible_only and not helperfunctions.errorbars_hidden(container)) or not visible_only): min_x, max_x, min_y, max_y = helperfunctions.get_errorbar_bounds(container) lower_xlim = min(lower_xlim, min_x) if min_x else lower_xlim upper_xlim = max(upper_xlim, max_x) if max_x else upper_xlim lower_ylim = min(lower_ylim, min_y) if min_y else lower_ylim upper_ylim = max(upper_ylim, max_y) if max_y else upper_ylim xys = [[lower_xlim, lower_ylim], [upper_xlim, upper_ylim]] # update_datalim will update limits with union of current lims and xys self.update_datalim(xys)
def _get_errorbars_props_from_curve(curve, props): """Get a curve's errorbar properties and add to props dict""" props['hide_errors'] = getattr(curve, 'hide_errors', errorbars_hidden(curve)) props['errorevery'] = getattr(curve, 'errorevery', 1) try: caps = curve[1] props['capsize'] = float(caps[0].get_markersize() / 2) props['capthick'] = float(caps[0].get_markeredgewidth()) except (IndexError, TypeError): props['capsize'] = 0.0 props['capthick'] = 1.0 try: bars = curve[2] props['elinewidth'] = float(bars[0].get_linewidth()[0]) props['ecolor'] = convert_color_to_hex(bars[0].get_color()[0]) except (IndexError, TypeError): props['elinewidth'] = 1.0 props['ecolor'] = convert_color_to_hex(rcParams['lines.color']) return props