Beispiel #1
0
 def test_curve_has_all_errorbars_on_replot_after_error_every_increase(
         self):
     fig = figure()
     ax = fig.add_subplot(111)
     curve = ax.errorbar([0, 1, 2, 4], [0, 1, 2, 4],
                         yerr=[0.1, 0.2, 0.3, 0.4])
     new_curve = CurvesTabWidgetPresenter.replot_curve(
         ax, curve, {'errorevery': 2})
     self.assertEqual(2, len(new_curve[2][0].get_segments()))
     new_curve = CurvesTabWidgetPresenter.replot_curve(
         ax, new_curve, {'errorevery': 1})
     self.assertTrue(hasattr(new_curve, 'errorbar_data'))
     self.assertEqual(4, len(new_curve[2][0].get_segments()))
Beispiel #2
0
    def toggle_error_bars_for(ax, curve, make_visible=None):
        # get all curve properties
        curve_props = CurveProperties.from_curve(curve)
        # and remove the ones that matplotlib doesn't recognise
        plot_kwargs = curve_props.get_plot_kwargs()
        new_curve = CurvesTabWidgetPresenter.replot_curve(
            ax, curve, plot_kwargs)

        # Inverts either the current state of hide_errors
        # or the make_visible kwarg that forces a state:
        # If make visible is True, then hide_errors must be False
        # for the intended effect
        curve_props.hide_errors = not curve_props.hide_errors if make_visible is None else not make_visible

        CurvesTabWidgetPresenter.toggle_errors(new_curve, curve_props)
        CurvesTabWidgetPresenter.update_limits_and_legend(ax)