Esempio n. 1
0
 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))
     # ErrorbarContainer does not have 'errorevery' as an attribute directly
     # So to get this property take from errorbar lines curve
     try:
         barlines = curve[2][0]
         props['errorevery'] = int(
             barlines.axes.creation_args[len(barlines.axes.creation_args) -
                                         1]['errorevery'])
     except (IndexError, TypeError, KeyError):
         props['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
         # if the errorbars don't have a default color, use the line's color
         props['ecolor'] = curve.get_color()
     return props
Esempio n. 2
0
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()
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
 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
         # if the errorbars don't have a default color, use the line's color
         props['ecolor'] = curve.get_color()
     return props