matplotlib.pyplot.grid

matplotlib.pyplot.grid(b=None, which='major', axis='both', **kwargs)[源代码]

配置网格线。

参数:
b布尔或无,可选

是否显示网格线。如果有的话 关键字参数 提供了,假定您希望打开网格,并且 b 将设置为“真”。

如果 bNone 没有 关键字参数 ,这将切换线条的可见性。

which{'major','minor','both'},可选

要应用更改的网格线。

axis'both'、'x'、'y',可选

要应用更改的轴。

**kwargsLine2D 性质line2d属性

定义网格的线条属性,例如:

grid(color='r', linestyle='-', linewidth=2)

有效的关键字参数为:

财产 描述
agg_filter 一种过滤函数,它接受一个(m,n,3)浮点数组和一个dpi值,并返回一个(m,n,3)数组。
alpha 浮动或无
animated 布尔
antialiased 或者aa 布尔
clip_box Bbox
clip_on 布尔
clip_path 面片或(路径、变换)或无
color 或c 颜色
contains 未知的
dash_capstyle “对接”、“圆形”、“突出”
dash_joinstyle 'miter'、'round'、'bevel'
dashes 浮动顺序(点中的开/关墨迹)或(无,无)
data (2,N)阵列或两个一维阵列
drawstyle 或ds {'default','steps','steps pre','steps mid','steps post'},default:'默认'
figure Figure
fillstyle 'full'、'left'、'right'、'bottom'、'top'、'none'
gid STR
in_layout 布尔
label 对象
linestyle 或ls '-'、'-'、'-'、'-'、':'、'、'、'(偏移量、开/关顺序)、…
linewidth 或lw 浮动
marker 标记样式字符串, PathMarkerStyle
markeredgecolor 或mec 颜色
markeredgewidth 或者喵喵 浮动
markerfacecolor 或mfc 颜色
markerfacecoloralt 或mfcalt 颜色
markersize 或ms 浮动
markevery None或int or(int,int)或slice或List [int] 或float或(float,float)或List [bool]
path_effects AbstractPathEffect
picker 未知的
pickradius 浮动
rasterized 布尔或无
sketch_params (比例:浮动,长度:浮动,随机性:浮动)
snap 布尔或无
solid_capstyle “对接”、“圆形”、“突出”
solid_joinstyle 'miter'、'round'、'bevel'
transform matplotlib.transforms.Transform
url STR
visible 布尔
xdata 一维阵列
ydata 一维阵列
zorder 浮动

笔记

轴作为一个单位绘制,因此绘制网格的有效zorder由每个轴的zorder决定,而不是由 Line2D 构成网格的对象。因此,要设置grid zorder,请使用 set_axisbelow 或者,为了获得更多的控制权,打电话给 set_zorder 每个轴的方法。