可以在任何 matplotlib 文本字符串中使用子 TeX 标记,将它放在一对美元符号($)内。

注意,你不需要安装 TeX,因为 matplotlib 提供了自己的 TeX 表达式解析器,布局引擎和字体。 布局引擎是 Donald Knuth 的 TeX 中的布局算法的一种相当直接的适配版,所以质量是相当不错的(matplotlib 还为那些想要调用 TeX 生成文本的人提供一个usetex选项(参见使用 LaTeX 渲染文本 )。

任何文本元素都可以使用数学文本。 你应该使用原始字符串(在引号前面加一个'r'),并用美元符号($)包围数学文本,如 TeX。 常规文本和数学文本可以在同一个字符串内交错。 Mathtext 可以使用 Computer Modern 字体(来自 (La)TeX),STIX 字体(为与 Times 混合使用而设计)或你提供的 Unicode 字体。 可以使用自定义变量mathtext.fontset选择 mathtext 字体(请参阅自定义 matplotlib

注意

在Python的 『narrow』 构建中,如果使用 STIX 字体,你还应该将ps.fonttypepdf.fonttype设置为 3(默认值),而不是 42。否则一些字符将不可见。

下面是个简单的例子:

# plain text
plt.title('alpha > beta')

生成alpha > beta

但是这个:

# math text
plt.title(r'$\alpha > \beta$')

生成

Matplotlib 中文用户指南 4.6 编写数学表达式_ci


注意

Mathtext 应该放在一对美元符号($)之间。 为了易于显示货币值,例如$ 100.00,如果整个字符串中存在单个美元符号,则它将被逐字显示为美元符号。 这是常规 TeX 的一个小改变,其中非数学文本中的美元符号必须被转义('$')。

注意

虽然一对美元符号($)内的语法是 TeX 风格的,但是外面的文本不是。 特别是,字符:

# $ % & ~ _ ^ \ { } \( \) \[ \]

在 TeX 中的数学模式之外有特殊的意义。 因此,根据rcParam text.usetex标志这些字符的表现有所不同。 更多信息请参阅usetex教程

下标和上标

为了制作下标和上标,使用_或者^符号:

r'$\alpha_i > \beta_i$'

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_02

一些符号会自动将它们的下标或上标放在操作符的底部或顶部,例如,为了编写 0 到无穷的

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_03

的和,你可以:

r'$\sum_{i=0}^\infty x_i$'

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_04

分数、二项式和堆叠数

可以使用\frac{}{}\binomial{}{}\stackrel{}{}命令分别创建分数,二项式和堆叠数字:

r'$\frac{3}{4} \binom{3}{4} \stackrel{3}{4}$'

产生

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_05

分数可以任意嵌套:

r'$\frac{5 - \frac{1}{x}}{4}$'

产生

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_06

请注意,在分数周围放置圆括号和花括号需要特别注意。 这种明显的方式会产生太小的括号:

r'$(\frac{5 - \frac{1}{x}}{4})$'

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_07

解决方案是在括号前面加上\left\right以通知解析器这些括号包含整个对象:

r'$\left(\frac{5 - \frac{1}{x}}{4}\right)$'

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_08

根式

根式可以有\sqrt[]{}产生,例如:

r'$\sqrt{2}$'

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_09

方括号内可以(可选地)设置任何底数。 请注意,底数必须是一个简单的表达式,并且不能包含布局命令,如分数或上下标:

r'$\sqrt[3]{x}$'

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_10

字体

用于数学符号的默认字体是斜体。

注意

此默认值可以使用mathtext.default rcParam更改。 这是非常有用的,例如,通过将其设置为regular,使用与常规非数学文本相同的字体作为数学文本。

为了修改字体,例如,以罗马字体编写sin,使用字体命令来闭合文本:

r'$s(t) = \mathcal{A}\mathrm{sin}(2 \omega t)$'

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_11

这里st是斜体(默认)的变量,sin是罗马字体,振幅A是书法字体。 注意在上面的例子中,Asin之间的间距被挤压。 你可以使用间距命令在它们之间添加一些空格:

s(t) = \mathcal{A}\/\sin(2 \omega t)

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_12

所有字体的可用选项为:

命令

结果

\mathrm{Roman}

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_13

\mathit{Italic}

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_14

\mathtt{Typewriter}

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_15

\mathcal{CALLIGRAPHY}

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_16

使用 STIX 字体时,你也可以选择:

命令

结果

\mathbb{blackboard}

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_17

\mathrm{\mathbb{blackboard}}

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_18

\mathfrak{Fraktur}

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_19

\mathsf{sansserif}

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_20

\mathrm{\mathsf{sansserif}}

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_21

\mathcircled{circled}

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_22

还有三个全局『字体集』可供选择,它们使用matplotlibrc中的mathtext.fontset参数进行选择。

cm: Computer Modern (TeX)

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_23

stix: STIX (为和 Times 混合使用而设计)

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_24

stixsans: STIX sans-serif

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_25

此外,你可以使用\mathdefault{...}或其别名\mathregular{...}来使用用于 mathtext 之外的常规文本的字体。 这种方法有一些限制,最明显的是,可以使用很少的符号,但可用于将数学表达式与图中的其他文本混合。

自定义字体

mathtext 还提供了一种对数学公式使用自定义字体的方法。 这种方法使用起来相当棘手,应该看做为有耐心的用户准备的试验特性。 通过将rcParam mathtext.fontset设置为custom,你可以设置以下参数,这些参数控制用于特定数学字符集的字体文件。

参数

相当于

mathtext.it

\mathit{} 默认斜体

mathtext.rm

\mathrm{} 罗马字体(upright)

mathtext.tt

\mathtt{} 打字机(monospace)

mathtext.bf

\mathbf{} 粗体

mathtext.cal

\mathcal{} 书法

mathtext.sf

\mathsf{} sans-serif

每个参数应该设置为fontconfig字体描述符(在尚未编写的字体章节中定义)。

所使用的字体应该具有 Unicode 映射,以便找到任何非拉丁字符,例如希腊语。 如果要使用未包含在自定义字体中的数学符号,可以将rcParam mathtext.fallback_to_cm设置为True,这将导致自定义字体中找不到特定字符时,数学文本系统使用默认的 Computer Modern 字体中的字符。

请注意,Unicode 中规定的数学字形随时间而演进,许多字体的字形对于 mathtext 可能不在正确位置。

重音符号

重音命令可以位于任何符号之前,在其上添加重音。 他们中的一些些拥有较长和较短的形式。

命令

结果

\acute a\'a

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_26

\bar a

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_27

\breve a

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_28

\ddot a\"a

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_29

\dot a\.a

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_30

\grave a\a`

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_31

\hat a\^a

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_32

\tilde a\~a

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_33

\vec a

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_34

\overline{abc}

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_35

另外有两个特殊的重音符号,可以自动调整为符号的宽度:

命令

结果

\widehat{xyz}

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_36

\widetilde{xyz}

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_37

当把重音放在小写的ij上时应该小心。 注意下面的\imath用来避免i上额外的点:

r"$\hat i\ \ \hat \imath$"

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_38

符号

你也可以使用更大量的 TeX 符号,比如\infty\leftarrow\sum\int

小写希腊字母

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_39

\alpha

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_40

\beta

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_41

\chi

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_42

\epsilon

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_43

\eta

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_44

\gamma

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_45

\lambda

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_46

\mu

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_47

\nu

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_48

\pi

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_49

\psi

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_50

\rho

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_51

\theta

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_52

\upsilon

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_53

\varepsilon

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_54

\varpi

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_55

\varrho

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_56

\varsigma

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_57

\zeta

大写希腊字母

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_58

\Delta

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_59

\Gamma

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_60

\Lambda

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_61

\Psi

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_62

\Sigma

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_63

\Theta

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_64

\nabla

希伯来文

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_65

\aleph

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_66

\beth

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_67

\daleth

分隔符

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_68

/

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_69

[

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_70

\Downarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_71

\downarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_72

\langle

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_73

\lceil

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_74

\rangle

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_75

\rceil

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_76

\rfloor

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_77

\vert

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_78

\{

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_79

|

大型符号

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_80

\bigcap

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_81

\bigcup

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_82

\bigodot

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_83

\biguplus

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_84

\bigvee

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_85

\bigwedge

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_86

\oint

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_87

\prod

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_88

\sum

标准函数名称

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_89

\Pr

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_90

\arccos

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_91

\arcsin

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_92

\arg

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_93

\cos

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_94

\cosh

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_95

\coth

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_96

\csc

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_97

\deg

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_98

\dim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_99

\exp

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_100

\gcd

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_101

\inf

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_102

\ker

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_103

\lg

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_104

\liminf

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_105

\limsup

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_106

\ln

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_107

\max

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_108

\min

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_109

\sec

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_110

\sinh

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_111

\sup

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_112

\tan

二元运算符和关系符号

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_113

\Bumpeq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_114

\Cap

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_115

\Cup

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_116

\Doteq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_117

\Join

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_118

\Subset

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_119

\Supset

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_120

\Vdash

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_121

\Vvdash

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_122

\approx

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_123

\approxeq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_124

\ast

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_125

\asymp

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_126

\backepsilon

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_127

\backsim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_128

\backsimeq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_129

\barwedge

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_130

\because

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_131

\between

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_132

\bigcirc

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_133

\bigtriangledown

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_134

\bigtriangleup

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_135

\blacktriangleleft

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_136

\blacktriangleright

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_137

\bot

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_138

\bowtie

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_139

\boxdot

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_140

\boxminus

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_141

\boxplus

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_142

\boxtimes

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_143

\bullet

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_144

\bumpeq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_145

\cap

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_146

\cdot

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_147

\circ

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_148

\circeq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_149

\coloneq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_150

\cong

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_151

\cup

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_152

\curlyeqprec

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_153

\curlyeqsucc

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_154

\curlyvee

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_155

\curlywedge

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_156

\dag

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_157

\dashv

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_158

\ddag

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_159

\diamond

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_160

\div

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_161

\divideontimes

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_162

\doteq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_163

\doteqdot

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_164

\dotplus

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_165

\doublebarwedge

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_166

\eqcirc

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_167

\eqcolon

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_168

\eqsim

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_169

\eqslantgtr

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_170

\eqslantless

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_171

\equiv

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_172

\fallingdotseq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_173

\frown

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_174

\geq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_175

\geqq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_176

\geqslant

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_177

\gg

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_178

\ggg

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_179

\gnapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_180

\gneqq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_181

\gnsim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_182

\gtrapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_183

\gtrdot

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_184

\gtreqless

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_185

\gtreqqless

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_186

\gtrless

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_187

\gtrsim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_188

\in

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_189

\intercal

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_190

\leftthreetimes

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_191

\leq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_192

\leqq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_193

\leqslant

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_194

\lessapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_195

\lessdot

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_196

\lesseqgtr

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_197

\lesseqqgtr

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_198

\lessgtr

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_199

\lesssim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_200

\ll

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_201

\lll

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_202

\lnapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_203

\lneqq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_204

\lnsim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_205

\ltimes

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_206

\mid

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_207

\models

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_208

\mp

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_209

\nVDash

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_210

\nVdash

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_211

\napprox

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_212

\ncong

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_213

\ne

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_214

\neq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_214

\neq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_216

\nequiv

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_217

\ngeq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_218

\ngtr

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_219

\ni

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_220

\nleq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_221

\nless

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_222

\nmid

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_223

\notin

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_224

\nparallel

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_225

\nprec

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_226

\nsim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_227

\nsubset

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_228

\nsubseteq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_229

\nsucc

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_230

\nsupset

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_231

\nsupseteq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_232

\ntriangleleft

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_233

\ntrianglelefteq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_234

\ntriangleright

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_235

\ntrianglerighteq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_236

\nvDash

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_237

\nvdash

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_238

\odot

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_239

\ominus

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_240

\oplus

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_241

\oslash

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_242

\otimes

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_243

\parallel

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_244

\perp

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_245

\pitchfork

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_246

\pm

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_247

\prec

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_248

\precapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_249

\preccurlyeq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_250

\preceq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_251

\precnapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_252

\precnsim

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_253

\precsim

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_254

\propto

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_255

\rightthreetimes

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_256

\risingdotseq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_257

\rtimes

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_258

\sim

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_259

\simeq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_260

\slash

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_261

\smile

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_262

\sqcap

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_263

\sqcup

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_264

\sqsubset

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_264

\sqsubset

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_266

\sqsubseteq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_267

\sqsupset

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_267

\sqsupset

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_269

\sqsupseteq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_270

\star

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_271

\subset

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_272

\subseteq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_273

\subseteqq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_274

\subsetneq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_275

\subsetneqq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_276

\succ

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_277

\succapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_278

\succcurlyeq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_279

\succeq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_280

\succnapprox

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_281

\succnsim

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_282

\succsim

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_283

\supset

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_284

\supseteq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_285

\supseteqq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_286

\supsetneq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_287

\supsetneqq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_288

\therefore

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_289

\times

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_290

\top

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_291

\triangleleft

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_292

\trianglelefteq

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_293

\triangleq

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_294

\triangleright

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_295

\trianglerighteq

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_296

\uplus

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_297

\vDash

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_298

\varpropto

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_299

\vartriangleleft

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_300

\vartriangleright

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_301

\vdash

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_302

\vee

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_303

\veebar

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_304

\wedge

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_305

\wr

箭头符号

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_70

\Downarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_307

\Leftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_308

\Leftrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_309

\Lleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_310

\Longleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_311

\Longleftrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_312

\Longrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_313

\Lsh

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_314

\Nearrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_315

\Nwarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_316

\Rightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_317

\Rrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_318

\Rsh

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_319

\Searrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_320

\Swarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_321

\Uparrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_322

\Updownarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_323

\circlearrowleft

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_324

\circlearrowright

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_325

\curvearrowleft

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_326

\curvearrowright

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_327

\dashleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_328

\dashrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_71

\downarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_330

\downdownarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_331

\downharpoonleft

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_332

\downharpoonright

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_333

\hookleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_334

\hookrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_335

\leadsto

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_336

\leftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_337

\leftarrowtail

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_338

\leftharpoondown

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_339

\leftharpoonup

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_340

\leftleftarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_341

\leftrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_342

\leftrightarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_343

\leftrightharpoons

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_344

\leftrightsquigarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_345

\leftsquigarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_346

\longleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_347

\longleftrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_348

\longmapsto

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_349

\longrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_350

\looparrowleft

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_351

\looparrowright

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_352

\mapsto

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_353

\multimap

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_354

\nLeftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_355

\nLeftrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_356

\nRightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_357

\nearrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_358

\nleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_359

\nleftrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_360

\nrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_361

\nwarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_362

\rightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_363

\rightarrowtail

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_364

\rightharpoondown

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_365

\rightharpoonup

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_366

\rightleftarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_366

\rightleftarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_368

\rightleftharpoons

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_368

\rightleftharpoons

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_370

\rightrightarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_370

\rightrightarrows

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_372

\rightsquigarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_373

\searrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_374

\swarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_375

\to

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_376

\twoheadleftarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_377

\twoheadrightarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_378

\uparrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_379

\updownarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_379

\updownarrow

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_381

\upharpoonleft

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_382

\upharpoonright

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_383

\upuparrows

杂项符号

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_384

\$

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_385

\AA

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_386

\Finv

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_387

\Game

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_388

\Im

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_389

\P

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_390

\Re

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_391

\S

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_392

\angle

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_393

\backprime

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_394

\bigstar

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_395

\blacksquare

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_396

\blacktriangle

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_397

\blacktriangledown

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_398

\cdots

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_399

\checkmark

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_400

\circledR

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_401

\circledS

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_402

\clubsuit

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_403

\complement

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_404

\copyright

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_405

\ddots

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_406

\diamondsuit

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_407

\ell

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_408

\emptyset

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_409

\eth

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_410

\exists

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_411

\flat

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_412

\forall

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_413

\hbar

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_414

\heartsuit

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_415

\hslash

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_416

\iiint

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_417

\iint

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_417

\iint

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_419

\imath

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_420

\infty

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_421

\jmath

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_422

\ldots

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_423

\measuredangle

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_424

\natural

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_425

\neg

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_426

\nexists

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_427

\oiiint

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_428

\partial

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_429

\prime

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_430

\sharp

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_431

\spadesuit

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_432

\sphericalangle

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_433

\ss

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_434

\triangledown

Matplotlib 中文用户指南 4.6 编写数学表达式_ci_435

\varnothing

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_436

\vartriangle

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_437

\vdots

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_438

\wp

Matplotlib 中文用户指南 4.6 编写数学表达式_字符串_439

\yen

如果特定符号没有名称(对于 STIX 字体中的许多较为模糊的符号也是如此),也可以使用 Unicode 字符:

ur'$\u23ce$'

示例

下面是个示例,在上下文中展示了许多这些特性。

import numpy as np
import matplotlib.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 > \beta_i$', fontsize=20)
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
         fontsize=20)
plt.xlabel('time (s)')
plt.ylabel('volts (mV)')
plt.show()

Matplotlib 中文用户指南 4.6 编写数学表达式_TeX_440