Python 绘图中的上标
要在 Python 中放置某个上标,我们可以采取以下步骤 -
使用 numpy,为 a 和 f 创建点。
使用 plot() 方法,用标签 f=ma 绘制 f = ma 曲线。
使用上标为该绘图添加标题,即 kgms-2。
使用上标为该绘图添加 xlabel,即 ms-2。
使用上标为该绘图添加 ylabel,即 kg。
要放置图例,请使用 legend() 方法。
要显示图形,请使用 show() 方法。
范例
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
a = np.linspace(1, 10, 100)
m = 20
f = m*a
plt.plot(a, f, c="red", lw=5, label="f=ma")
plt.title("Force $\mathregular{kgms^{-2}}$")
plt.xlabel("Acceleration $\mathregular{ms^{-2}}$")
plt.ylabel("Acceleration $\mathregular{kg}$")
plt.legend()
plt.show()输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP