Skip to content

Commit

Permalink
Added a gentle matplotlib version check in graphFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
hwdro committed Dec 7, 2010
1 parent ab26acb commit dc09662
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions gui/graphFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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("")
Expand Down

0 comments on commit dc09662

Please sign in to comment.