简体   繁体   中英

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

I have such a piece of code for plotting:

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

And it gives me:

在此处输入图片说明

How the number of grid lines can be increased in seaborn, to make it denser?

Based on this question : add minor gridlines to matplotlib plot using seaborn , you can do it like that.

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)

You obtain this figure :

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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