def test_calling_create_legend_with_no_props_adds_legend_to_plot(self): ax = mock.Mock(spec=MantidAxes) ax.lines = [mock.Mock()] LegendProperties.create_legend(props=None, ax=ax) ax.legend.assert_called_once()
def update_legend(ax, legend): if not legend["exists"] and ax.get_legend(): ax.get_legend().remove() return if legend["exists"]: LegendProperties.create_legend(legend, ax)
def apply_properties(self): """Takes the properties from the view and creates a new legend.""" props = self.view.get_properties() if self.current_view_properties == props: return for ax in self.axes: LegendProperties.create_legend(props, ax) self.current_view_properties = props
def test_calling_create_legend_with_no_props_uses_config_values_in_legend( self, mock_ConfigService): ax = mock.Mock(spec=MantidAxes) ax.lines = [mock.Mock()] LegendProperties.create_legend(props=None, ax=ax) mock_ConfigService.getString.assert_has_calls([ mock.call('plots.legend.Location'), mock.call('plots.legend.FontSize') ]) ax.legend.assert_called_once_with(handles=mock.ANY, loc='best', prop={"size": 8.0})
def update_limits_and_legend(ax, legend_props=None): ax.relim() ax.autoscale() if legend_props: LegendProperties.create_legend(legend_props, ax)
def test_calling_create_legend_with_no_props_adds_legend_to_plot(self): ax = plt.gca() LegendProperties.create_legend(props=None, ax=ax) self.assertNotEqual(ax.get_legend(), None)