diff --git a/src/sas/qtgui/Plotting/Plotter.py b/src/sas/qtgui/Plotting/Plotter.py index 357707501c..f9ec588f61 100644 --- a/src/sas/qtgui/Plotting/Plotter.py +++ b/src/sas/qtgui/Plotting/Plotter.py @@ -88,6 +88,8 @@ def __init__(self, parent=None, manager=None, quickplot=False): self.toolbar._actions['pan'].triggered.connect(self._pan) self.toolbar._actions['zoom'].triggered.connect(self._zoom) + self.legendVisible = True + parent.geometry() @property @@ -258,7 +260,7 @@ def plot(self, data=None, color=None, marker=None, hide_error=False, transform=T self.legend = ax.legend(loc='upper right', shadow=True) if self.legend: self.legend.set_picker(True) - + self.legend.set_visible(self.legendVisible) # Current labels for axes if self.yLabel and not is_fit: ax.set_ylabel(self.yLabel) @@ -303,7 +305,7 @@ def onResize(self, event): """ Resize the legend window/font on canvas resize """ - if not self.showLegend: + if not self.showLegend or not self.legendVisible: return width = _legendResize(event.width, self.parent) # resize the legend to follow the canvas width. @@ -799,8 +801,9 @@ def onToggleLegend(self): if not self.showLegend: return - visible = self.legend.get_visible() - self.legend.set_visible(not visible) + #visible = self.legend.get_visible() + self.legendVisible = not self.legendVisible + self.legend.set_visible(self.legendVisible) self.canvas.draw_idle() def onCusotmizeLabel(self):