matplotlib、seaborn又一个强力统计分析助手
分享一个强大的Python可视化扩展工具—plotastic!
它极大地弥补了Matplotlib和Seaborn在统计分析功能方面的不足。
借助plotastic,你可以:
使用方法有点类似新版的seaborn,
plst.set_palette(["tomato", "royalblue"], verbose=False)(
DA1.subplots(figsize=(3, 2))
# 绘图
.fillaxes(kind="swarm", dodge=True, size=1.8, alpha=0.8) # 绘制散点图
.fillaxes(
kind="box", # 绘制箱线图
#散点图、箱线图美化
whiskerprops=dict(linewidth=0),
boxprops=dict(linewidth=0, fill=False),
medianprops=dict(linewidth=0),
showmeans=True,
meanprops=dict(marker="_", markeredgecolor="black"),
showfliers=False,
)
# 坐标轴、图例美化
.edit_y_scale_log(10)
.edit_y_ticklabels_log_minor(subs=[0, 1, 2, 5])
.edit_y_ticklabel_percentage()
.annotate_pairwise(only_sig="all", include="__hue")
.edit_titles(axtitles=["Non-Smoker", "Smoker"])
.edit_xy_axis_labels(y="Tip [%]", x="")
.edit_legend(capitalize_title=True)
)
# 保存图片
plt.savefig("tips1.png", dpi=300, bbox_inches="tight")
使用plotastic前需要安装Python >= 3.11、pandas == 1.5.3和seaborn <= 0.12.2。
ref:https://github.com/markur4/plotastic
-END-
推荐阅读:
👉Python matplotlib保姆级教程 👉Python seaborn保姆级教程
交流学习