When working with formulas in a Python drawing, solve the problem that the font of \frac{}{} is too small

Source: Internet
Author: User

When using matplotlib drawing to add a formula to a picture, it is generally necessary to use the text or annotate function, combined with latex grammar ' $...$ '.

For fractions, if you use \frac{}{} directly, the characters on the numerator denominator are small, as shown in the Green formula.

To solve this problem, we need to use the \displaystyle, that is, using the ' $\displaystyle ...$ ', as shown in the Blue formula in the effect. However, the prerequisite for using this is that the system is equipped with latex. (I use Protext, as: http://mirrors.ibiblio.org/CTAN/systems/windows/protext/do not miktex because the download package often fails, So simply install a more complete set of things. In addition to using Tex in the program, add the following code:

mpl.rcparams[' Text.usetex ') = True

Attached picture code:

xx = Linspace ( -3,3,100)
YY = exp (-xx**2)
Xlim (-4, 3)
Plot (Xx,yy, ' m ')
Text ( -3.5,0.80,r ' $y ={\rm exp}\left (-\alpha \left (\frac{x}{r}\right) ^2\right)$ ', color= ' G ')
Text ( -3.5,0.62,r ' $\displaystyle y={\rm exp}\left (-\alpha \left (\frac{x}{r}\right) ^2\right)$ ', color= ' B ')

When working with formulas in a Python drawing, solve the problem that the font of \frac{}{} is too small

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• Sales Support

1 on 1 presale consultation

• After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.