matplotlib.pyplot.xkcd#

matplotlib.pyplot.xkcd(scale=1, length=100, randomness=2)[源代码][源代码]#

开启 xkcd 素描风格绘图模式。

这只会对调用此函数后绘制的内容产生影响。

为了获得最佳效果,请安装 xkcd 脚本 字体;xkcd 字体未与 Matplotlib 打包在一起。

参数:
比例浮点数,可选

垂直于源线方向的摆动幅度。

长度浮点数,可选

沿线的摆动长度。

随机性浮点数,可选

长度被缩小或扩大的比例因子。

注释

此功能通过多个 rcParams 工作,因此它可能会覆盖您之前设置的其他参数。

如果你想让这个函数的效果是临时的,它可以作为一个上下文管理器使用,例如:

with plt.xkcd():
    # This figure will be in XKCD-style
    fig1 = plt.figure()
    # ...

# This figure will be in regular style
fig2 = plt.figure()

使用 matplotlib.pyplot.xkcd 的示例#

XKCD

XKCD