How can I format a float using matplotlib's LaTeX formatter?

前端 未结 3 1460
南笙
南笙 2020-12-20 18:10

I have a number in my python script that I want to use as part of the title of a plot in matplotlib. Is there a function that converts a float to a formatted TeX string?

3条回答
  •  我在风中等你
    2020-12-20 18:16

    You can do something like:

    ax.set_title( "${0} \\times 10^{{{1}}}$".format('3.5','+20'))
    

    in the old style:

    ax.set_title( "$%s \\times 10^{%s}$" % ('3.5','+20'))
    

提交回复
热议问题