如何修复 matplotlib OSError: xkcd not found in the style library
问题:
尝试使用以下命令启用 matplotlib xkcd 样式时
xkcd_style_error.py
plt.style.use("xkcd")你看到以下错误消息:
xkcd_error.txt
OSError: 'xkcd' not found in the style library and input is not a valid URL or path; see `style.available` for list of available styles解决方案
你不能通过运行 plt.style.use("xkcd") 启用 xkcd 样式绘图。而是使用 with plt.xkcd():
xkcd_style_fix.py
with plt.xkcd():
# TODO 你的绘图代码放在这里!
# plt.plot(x, y) # ExampleCheck out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow