- 模块:
matplotlib.pyplot
- 方法:
boxplot()
1. 基础绘图
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery') '#设置绘图格式
# make data:
np.random.seed(10)
D = np.random.normal((3, 5, 4), (1.25, 1.00, 1.25), (100, 3)) #构建数据
# plot
fig, ax = plt.subplots() #构建画板和画布
VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True,
showmeans=False, showfliers=False,
medianprops={"color": "white", "linewidth": 0.5},
boxprops={"facecolor": "C0", "edgecolor": "white",
"linewidth": 0.5},
whiskerprops={"color": "C0", "linewidth": 1.5},
capprops={"color": "C0", "linewidth": 1.5}) #对画布 ax 调用方法 boxplot
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
ylim=(0, 8), yticks=np.arange(1, 8))
plt.show() #展示图像,示例一

示例一
2. 参数
网友评论