JupyterLab #
Extensions out of sync? #
Go to <python>\share\jupyter\lab\settings
, edit (or delete) those JSON files.
Matplotlib #
绘制横线 #
plt.axhline(y, color, xmin, xmax, linestyle)
python
双 Y 轴 #
From https://matplotlib.org/stable/gallery/spines/multiple_yaxis_with_spines.html
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
twin1 = ax.twinx()
p1, = ax.plot([0, 1, 2], [0, 1, 2], "b-", label="Density")
p2, = twin1.plot([0, 1, 2], [0, 3, 2], "r-", label="Temperature")
ax.set_xlim(0, 2)
ax.set_ylim(0, 2)
twin1.set_ylim(0, 4)
ax.set_xlabel("Distance")
ax.set_ylabel("Density")
twin1.set_ylabel("Temperature")
ax.legend(handles=[p1, p2])
plt.show()
python
size #
plot
中使用 markersize
或者 ms
来修改点的大小, 而在 scatter
中直接使用 size
或 s
即可.
Scipy #
B-Spline #
from scipy.interpolate import make_interp_spline
xx = np.linspace(x.min(), x.max(), 400)
plt.plot(xx, make_interp_spline(x, y, k=2)(xx))
python
numpy #
同阶矩阵逐项相乘 #
称为 Hadamard Product(哈达玛积),np.multiply()
得到
pandas #
Rolling Mean #
From https://stackoverflow.com/a/49016377/8810271
类似股票 n 日均线,或者示波器采样平均值
df.rolling(100).mean()
python