def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None):
 from matplotlib import figure
 from matplotlib.backends import backend_agg
 if (prop is None):
  prop = FontProperties()
 parser = MathTextParser(u'path')
 (width, height, depth, _, _) = parser.parse(s, dpi=72, prop=prop)
 fig = figure.Figure(figsize=((width / 72.0), (height / 72.0)))
 fig.text(0, (depth / height), s, fontproperties=prop)
 backend_agg.FigureCanvasAgg(fig)
 fig.savefig(filename_or_obj, dpi=dpi, format=format)
 return depth

def math_to_image ( s , filename_or_obj , prop = None , dpi = None , format = None ) : from matplotlib import figure from matplotlib . backends import backend_agg if ( prop is None ) : prop = FontProperties ( ) parser = MathTextParser ( u'path' ) ( width , height , depth , _ , _ ) = parser . parse ( s , dpi = 72 , prop = prop ) fig = figure . Figure ( figsize = ( ( width / 72.0 ) , ( height / 72.0 ) ) ) fig . text ( 0 , ( depth / height ) , s , fontproperties = prop ) backend_agg . FigureCanvasAgg ( fig ) fig . savefig ( filename_or_obj , dpi = dpi , format = format ) return depth
given a math expression .