matplotlib.pyplot.xkcd#
- matplotlib.pyplot.xkcd(scale=1, length=100, randomness=2)[源代码]#
开启xkcd手绘风格绘图模式。
这只对在该函数调用后绘制的内容生效。
为了获得最佳效果,请安装xkcd 脚本字体;Matplotlib 不包含 xkcd 字体。
- 参数:
- scale浮点型,可选
垂直于源线摆动的幅度。
- length浮点型,可选
沿线摆动的长度。
- randomness浮点型,可选
长度收缩或扩展的比例因子。
备注
此函数通过一系列 rcParams 参数工作,因此它可能会覆盖您之前设置的其他参数。
如果您希望此函数的效果是临时的,它可以作为上下文管理器使用,例如
with plt.xkcd(): # This figure will be in XKCD-style fig1 = plt.figure() # ... # This figure will be in regular style fig2 = plt.figure()