From dc096621e145590f3244ab0b613bd65a63f7debf Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Tue, 7 Dec 2010 10:21:22 +0200 Subject: [PATCH] Added a gentle matplotlib version check in graphFrame --- gui/graphFrame.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/gui/graphFrame.py b/gui/graphFrame.py index 002e5f6bf7..c8e25c98c7 100644 --- a/gui/graphFrame.py +++ b/gui/graphFrame.py @@ -34,6 +34,8 @@ def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_ global enabled global mplImported + + self.legendFix = False if not enabled: return @@ -44,6 +46,10 @@ def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_ from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas from matplotlib.figure import Figure enabled = True + if mpl.__version__[0] != "1": + print "pyfa: Found matplotlib version ",mpl.__version__, " - activating OVER9000 workarounds" + print "pyfa: Recommended minimum matplotlib version is 1.0.0" + self.legendFix = True except: print "Problems importing matplotlib; continuing without graphs" enabled = False @@ -198,13 +204,21 @@ def draw(self, event=None): except: self.SetStatusText("Invalid values in '%s'" % fit.name) - leg = self.subplot.legend(tuple(legend), "upper right" , shadow = False) + if self.legendFix and len(legend) > 0: + leg = self.subplot.legend(tuple(legend), "upper right" , shadow = False) + for t in leg.get_texts(): + t.set_fontsize('small') + + for l in leg.get_lines(): + l.set_linewidth(1) - for t in leg.get_texts(): - t.set_fontsize('small') + elif not self.legendFix and len(legend) >0: + leg = self.subplot.legend(tuple(legend), "upper right" , shadow = False, frameon = False) + for t in leg.get_texts(): + t.set_fontsize('small') - for l in leg.get_lines(): - l.set_linewidth(1) + for l in leg.get_lines(): + l.set_linewidth(1) self.canvas.draw() self.SetStatusText("")