# How to write equations in matplotlib.pyplot¶

Practice makes perfect

In [4]:
import pandas as pd
import matplotlib.pyplot as plt

In [5]:
a = r'3 = frac{12}{4}'
ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')
plt.text(0.4,0.4,'$print('Source: ','https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/mathtext_examples.html')  Source: https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/mathtext_examples.html  In [6]: a = r'16 = {8}*{2}' ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height ax.set_xticks([]) ax.set_yticks([]) ax.axis('off') plt.text(0.4,0.4,'$print('source: ','https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/mathtext_examples.html')
print('We create a mathematical formula in Python:')

source:  https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/mathtext_examples.html
We create a mathematical formula in Python:

In [7]:
a = r'25 = {5}^{2}'
ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')
plt.text(0.4,0.4,'$print('We create a mathematical formula in Python:')  We create a mathematical formula in Python:  In [8]: a = r'13.8 = {15.9}-{2.1}' ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height ax.set_xticks([]) ax.set_yticks([]) ax.axis('off') plt.text(0.4,0.4,'$print('We create a mathematical formula in Python:')

We create a mathematical formula in Python:

In [9]:
a = r'14.3 = ({1.7}-{2.4})+15'
ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')
plt.text(0.4,0.4,'$print('We create a mathematical formula in Python:')  We create a mathematical formula in Python:  In [10]: a = r'0.4938 = ({2.07}-{1.3})^{2.7}' ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height ax.set_xticks([]) ax.set_yticks([]) ax.axis('off') plt.text(0.4,0.4,'$print('We create a mathematical formula in Python:')

We create a mathematical formula in Python:

In [11]:
a = r'x = sqrt{2.1*pi}'
ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')
plt.text(0.4,0.4,'$print('We create a mathematical formula in Python:')  We create a mathematical formula in Python:  In [12]: a = r'n = sqrt[3]{15}' ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height ax.set_xticks([]) ax.set_yticks([]) ax.axis('off') plt.text(0.4,0.4,'$print('Please calculate in Tensorflow the value of n:')

Please calculate in Tensorflow the value of n:

In [13]:
a = r'n = sqrt[4]{e}'
ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')
plt.text(0.4,0.4,'$print('Please calculate in Tensorflow the value of n:')  Please calculate in Tensorflow the value of n:  In [14]: a = r'W^{3beta}_{delta_1 rho_1 sigma_2} = U^{3beta}_{delta_1 rho_1} + frac{1}{8 pi 2} int^{alpha_2}_{alpha_2} d alpha^prime_2 left[frac{ U^{2beta}_{delta_1 rho_1} - alpha^prime_2U^{1beta}_{rho_1 sigma_2} }{U^{0beta}_{rho_1 sigma_2}}right]' ax = plt.axes([0,0,0.3,0.3]) #left,bottom,width,height ax.set_xticks([]) ax.set_yticks([]) ax.axis('off') plt.text(0.4,0.4,'$print('Please calculate in Tensorflow the value of n:')

Please calculate in Tensorflow the value of n: