Skip to main content
 首页 » 编程设计

python之seaborn 修改 y Axis (对数刻度)以显示更多值

2025年05月04日9bonelee

我使用 seaborn 绘制了一个箱线图,y Axis 使用对数刻度(时间以毫秒为单位)。我想通过在 Axis 上包含更多值来使 y Axis 更清晰。我怎样才能做到这一点?使用的代码和生成的图表如下。

ax2 = sns.boxplot(x="xVals", y="Time", data=df2, whis=[0, 100]) 
ax2.set(yscale="log") 

请您参考如下方法:

尝试

ax2.xaxis.set_major_locator(ticker.MultipleLocator(5)) 
ax2.xaxis.set_minor_locator(ticker.MultipleLocator(1)) 

更多信息:

https://matplotlib.org/api/ticker_api.html