选择style
用法
#使用bmh
plt.style.use('bmh')
其余style参考:
Style sheets reference
设定plt参数:rcparameter
plt.rcParams.update({
"legend.fancybox": True,
"legend.frameon": True,
# "text.usetex": True,
"font.family": "serif",
"font.serif": ["Times"],
"lines.markersize": 2.5,
"lines.linewidth":0.8,
"font.size":6})
设定Times New Roman 字体,显示not found
原问题
sudo apt install msttcorefonts -qq
rm ~/.cache/matplotlib -rf
分辨率
plt.savefig('filename.pdf')
手动设定分辨率
plt.savefig('filename.png', dpi=1000)
CDF曲线
PDF:probability density function 概率密度函数
CDF:cumulative distribution function 累积分布函数
pdf和cdf用于描述连续随机变量的概率分布
对于随机变量
X
=
[
x
1
,
x
2
.
.
.
x
N
]
X = [x_1,x_2...x_N]
X=[x1,x2...xN],pdf表示
P
∣
(
x
=
x
m
)
P|(x=x_m)
P∣(x=xm),即当x为
x
m
x_m
xm时的概率
常见的pdf有正态分布和高斯分布等
对于pdf,概率曲线的面积(积分)等于1
CDF为
P
∣
(
x
<
=
x
m
)
P|(x<=x_m)
P∣(x<=xm),即当x小于等于xm时的概率,相当于在PDF图形基础上,x小于等于xm部分的面积(积分)
Python实现
# create some randomly ddistributed data:
data = np.random.randn(10000)
# sort the data:
data_sorted = np.sort(data)
# calculate the proportional values of samples
p = 1. * np.arange(len(data)) / (len(data) - 1)
# plot the sorted data:
fig = plt.figure()
ax1 = fig.add_subplot(121)
ax1.plot(p, data_sorted)
ax1.set_xlabel('$p$')
ax1.set_ylabel('$x$')
ax2 = fig.add_subplot(122)
ax2.plot(data_sorted, p)
ax2.set_xlabel('$x$')
ax2.set_ylabel('$p$')