繁体   English   中英

如何在seaborn中增加网格线的数量?

[英]How the number of grid lines can be increased in seaborn?

我有这样一段用于绘图的代码:

sns.set_style("darkgrid")
fig, ax = plt.subplots(1, 1)    
        
x = np.arange(10)
ax.plot(x, x)

它给了我:

在此处输入图片说明

如何在 seaborn 中增加网格线的数量,使其更密集?

基于这个问题: 使用 seaborn 向 matplotlib 图中添加次要网格线,您可以这样做。

sns.set_style("darkgrid")
fig, ax = plt.subplots(1, 1)    
    
x = np.arange(10)
ax.plot(x, x)
ax.get_xaxis().set_minor_locator(mpl.ticker.AutoMinorLocator())
ax.get_yaxis().set_minor_locator(mpl.ticker.AutoMinorLocator())
ax.grid(b=True, which='major', color='w', linewidth=1.0)
ax.grid(b=True, which='minor', color='w', linewidth=0.5)

你得到这个数字:

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM