Open AllanChain opened 3 years ago
View Post on Blog
记录一些我实际遇到的关于 Jupyter 使用,Numpy 和 Pandas 数据处理,以及 Matplotlib 绘图相关的一些问题和解决方案。
Go to <python>\share\jupyter\lab\settings, edit (or delete) those JSON files.
<python>\share\jupyter\lab\settings
官方 cheat sheet
plt.axhline(y, color, xmin, xmax, linestyle)
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()
plot 中使用 markersize 或者 ms 来修改点的大小, 而在 scatter 中直接使用 size 或 s 即可.
plot
markersize
ms
scatter
size
s
scipy doc
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))
称为 Hadamard Product(哈达玛积),np.multiply() 得到
np.multiply()
From https://stackoverflow.com/a/49016377/8810271
类似股票 n 日均线,或者示波器采样平均值
df.rolling(100).mean()
View Post on Blog
JupyterLab
Extensions out of sync?
Go to
<python>\share\jupyter\lab\settings
, edit (or delete) those JSON files.Matplotlib
官方 cheat sheet
绘制横线
双 Y 轴
From https://matplotlib.org/stable/gallery/spines/multiple_yaxis_with_spines.html
size
plot
中使用markersize
或者ms
来修改点的大小, 而在scatter
中直接使用size
或s
即可.Scipy
B-Spline
scipy doc
numpy
同阶矩阵逐项相乘
称为 Hadamard Product(哈达玛积),
np.multiply()
得到pandas
Rolling Mean
From https://stackoverflow.com/a/49016377/8810271
类似股票 n 日均线,或者示波器采样平均值