gpt4 book ai didi

没有 xserver 的 Linux 系统上的 Python 绘图

转载 作者:太空宇宙 更新时间:2023-11-03 18:12:15 25 4
gpt4 key购买 nike

我是 python 新手,正在尝试探索图形,您能否帮助我了解我是否可以在没有运行 XSERVER 的 Linux 系统上使用 matplotlib 在控制台上绘制图形?

谢谢。

最佳答案

您可以在没有 X 服务器的情况下使用 matplotlib setting the backendAggPSPDFSVGCairoGDK (取决于您要创建的文件类型)。您可以在your matplotlibrc file中设置后端,根据您的安装,它可能位于 ~/~/.matplotlib~/.config/matplotlib/ 等目录中>。

或者,您可以在脚本本身中设置后端。在导入其他模块(例如 pyplot 等)之前,请务必先设置后端:

import matplotlib
matplotlib.use("Agg")

查看此SO question例如。

关于没有 xserver 的 Linux 系统上的 Python 绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25702285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com