@@ -563,7 +563,8 @@ def get_depth(self, texstr, dpi=120, fontsize=14):
563563 return depth
564564
565565
566- def math_to_image (s , filename_or_obj , prop = None , dpi = None , format = None ):
566+ def math_to_image (s , filename_or_obj , prop = None , dpi = None , format = None ,
567+ color = None ):
567568 """
568569 Given a math expression, renders it in a closely-clipped bounding
569570 box to an image file.
@@ -582,14 +583,16 @@ def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None):
582583 format : str, optional
583584 The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the
584585 format is determined as for `.Figure.savefig`.
586+ color : str, optional
587+ Foreground color, if not set the color is determined by rc params.
585588 """
586589 from matplotlib import figure
587590
588591 parser = MathTextParser ('path' )
589592 width , height , depth , _ , _ = parser .parse (s , dpi = 72 , prop = prop )
590593
591594 fig = figure .Figure (figsize = (width / 72.0 , height / 72.0 ))
592- fig .text (0 , depth / height , s , fontproperties = prop )
595+ fig .text (0 , depth / height , s , fontproperties = prop , color = color )
593596 fig .savefig (filename_or_obj , dpi = dpi , format = format )
594597
595598 return depth
0 commit comments