English 中文(简体)
Mathematical Expressions
  • 时间:2024-10-18

Matplotpb - Mathematical Expressions


Previous Page Next Page  

You can use a subset TeXmarkup in any Matplotpb text string by placing it inside a pair of dollar signs ($).

# math text
plt.title(r $alpha > eta$ )

To make subscripts and superscripts, use the _ and ^ symbols −

r $alpha_i> eta_i$ 

import numpy as np
import matplotpb.pyplot as plt
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)

plt.plot(t,s)
plt.title(r $alpha_i> eta_i$ , fontsize=20)

plt.text(0.6, 0.6, r $mathcal{A}mathrm{sin}(2 omega t)$ , fontsize = 20)
plt.text(0.1, -0.5, r $sqrt{2}$ , fontsize=10)
plt.xlabel( time (s) )
plt.ylabel( volts (mV) )
plt.show()

The above pne of code will generate the following output −

Mathematical Expressions Advertisements