簡體   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