当前位置:网站首页>Visual solutions to common problems (VIII) mathematical formulas
Visual solutions to common problems (VIII) mathematical formulas
2022-04-23 10:53:00 【The big pig of the little pig family】
The mathematical formula
One . Preface
When visualizing , We often encounter the situation of drawing some formulas , These formulas appear in the legend 、 Axis labels and titles , The problem is that if you use ordinary strings to write formulas, the display effect is very poor , The comparison is as follows :
You can see that the legend on the left is irregular and unsightly , But with the LaTeX
The formula shows that the effect has been greatly improved .
Two . Solution
Matplotlib Internal LaTeX
Parser and layout engine . So you can use it directly LaTeX
Write the formula .
Draw two functions as an example :
- ∑ 1 n x + 3 \sum_{1}^{n} x+3 ∑1nx+3
- sin x cos x \sin x \cos x sinxcosx
The complete procedure is as follows :
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['SimHei'] # Settings support Chinese
plt.rcParams['axes.unicode_minus'] = False # Set up - Number
# obtain X and Y
n = 15
x_1 = np.arange(1, n+1, 1)
y_1 = np.cumsum(x_1) + 3
x_2 = np.arange(0, 2*np.pi, np.pi/36)
y_2 = np.sin(x_2) * np.cos(x_2)
figure, ax = plt.subplots(1, 2)
# mapping
ax[0].plot(x_1, y_1, lw=3, color='k', label='$\sum_{1}^{n}x+3}$')
ax[0].set_title('$\sum_{1}^{n}x+3}$ function ', fontsize=20)
ax[0].set_xlabel("X", fontsize=15)
ax[0].set_ylabel('$\sum_{1}^{n}x+3}$ function ', fontsize=15)
ax[0].legend()
ax[1].plot(x_2, y_2, lw=3, color='r', label='$\sin x \cos x$')
ax[1].set_title('$\sin x \cos x$ function ', fontsize=20)
ax[1].set_xlabel("X", fontsize=15)
ax[1].set_ylabel('$\sin x \cos x$ function ', fontsize=15)
ax[1].legend()
plt.show()
2.1 The legend uses a mathematical formula
2.2 The title uses mathematical formulas
2.3 Axis labels use mathematical formulas
3、 ... and . Reference resources
版权声明
本文为[The big pig of the little pig family]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230617063531.html
边栏推荐
- UDP basic learning
- Swagger2 自定义参数注解如何不显示
- Learning note 5 - gradient explosion and gradient disappearance (k-fold cross verification)
- Reading integrity monitoring techniques for vision navigation systems - 3 background
- What about Jerry's stack overflow? [chapter]
- 解决方案架构师的小锦囊 - 架构图的 5 种类型
- Deploy jar package
- 1、两数之和(哈希表)
- Introduction to data analysis 𞓜 kaggle Titanic mission (III) - > explore data analysis
- Yarn core parameter configuration
猜你喜欢
Xshell+Xftp 下载安装步骤
Swagger2 自定义参数注解如何不显示
C language - custom type
景联文科技—专业数据标注公司和智能数据标注平台
【leetcode】199. Right view of binary tree
/Can etc / shadow be cracked?
Diary of dishes | Blue Bridge Cup - hexadecimal to octal (hand torn version) with hexadecimal conversion notes
部署jar包
Cve-2019-0708 vulnerability exploitation of secondary vocational network security 2022 national competition
比深度学习更值得信赖的模型ART
随机推荐
Ueditor -- limitation of 4m size of image upload component
Code implementation of general bubbling, selection, insertion, hill and quick sorting
Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
Xdotool key Wizard
链表相交(链表)
SQLServer 查询数据库死锁
Manjaro installation and configuration (vscode, wechat, beautification, input method)
/Can etc / shadow be cracked?
Detailed explanation of MapReduce calculation process
ID number verification system based on visual structure - Raspberry implementation
Hikvision face to face summary
Contact between domain name and IP address
Yarn resource scheduler
MySQL how to merge the same data in the same table
一个微博数据库设计带来的简单思考
Leetcode22: bracket generation
RESTful和SOAP的区别
Define linked list (linked list)
Linked list intersection (linked list)
Resolution and size of mainstream mobile phones