首页 > 解决方案 > 为什么 seaborn 样式在 matplotlib 中不起作用?

问题描述

直到最近在设置我的 matplotlib 绘图的样式时,我都会使用 seaborn-darkgrid。下面的代码工作了很长时间,但现在它只显示默认样式。我认为我的代码有问题,但现在我在线查看 Matplotlib 样式表参考页面,它的 seaborn 样式图也显示为默认样式。

matplotlib.pyplot.style 不再支持 seaborn 样式吗?

链接:https ://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html

import matplotlib.pyplot as plt
import seaborn as sns


%matplotlib inline

plt.style.use('seaborn-darkgrid')
dfLOADA = df_dayM[['InfNH3', 'EffNH3']]
plt.plot(dfLOADA)
plt.title('Influent and Effluent NH3: ' + month) 
plt.xticks(dfLOADA.index[::7])
plt.legend(dfLOADA.columns)
plt.xlabel('Time [days]')
plt.ylabel('[mg NH3/L]')
plt.show()

标签: matplotlibseaborn

解决方案


推荐阅读