所有可用的 matplotlib 后端的列表
当前后端名称可通过以下方式访问:
>>> import matplotlib.pyplot as plt >>> plt.get_backend() 'GTKAgg'
有没有办法获取可在特定计算机上使用的所有后端的列表?
The current backend name is accessible via
>>> import matplotlib.pyplot as plt >>> plt.get_backend() 'GTKAgg'
Is there a way to get a list of all backends that can be used on a particular machine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以访问列表,
第三个列表是前两个列表的串联。如果我正确地阅读了源代码,那么这些列表是硬编码的,并且不会告诉您哪些后端实际上可用。还有,
但这也只检查硬编码列表。
You can access the lists
the third being the concatenation of the former two. If I read the source code correctly, those lists are hard-coded though, and don't tell you what backends are actually usable. There is also
but this also only checks against the hard-coded list.
这是对之前发布的脚本的修改。它找到所有支持的后端,验证它们并测量它们的 fps。在 OSX 上,当涉及到 tkAgg 时,它会使 python 崩溃,因此使用时需要您自担风险;)
要查看支持的交互式后端,请参阅:
Here is a modification of the script posted previously. It finds all supported backends, validates them and measures their fps. On OSX it crashes python when it comes to tkAgg, so use at your own risk ;)
To just see supported interactive backends see:
您可以假装输入错误的后端参数,然后它会返回一个 ValueError 以及有效的 matplotlib 后端列表,如下所示:
输入:
输出:
You can pretend to put a wrong backend argument, then it will return you a ValueError with the list of valid matplotlib backends, like this:
Input:
Output:
Sven 提到了硬编码列表,但要找到 Matplotlib 可以使用的每个后端(基于设置后端的当前实现),可以检查 matplotlib/backends 文件夹。
以下代码执行此操作:
There is the hard-coded list mentioned by Sven, but to find every backend which Matplotlib can use (based on the current implementation for setting up a backend) the matplotlib/backends folder can be inspected.
The following code does this:
您还可以在此处查看一些后端的一些文档:
http://matplotlib.org/api/index_backend_api.html
页面仅列出了一些后端,其中一些没有适当的文档:
You can also see some documentation for a few backends here:
http://matplotlib.org/api/index_backend_api.html
the pages lists just a few backends, some of them don't have a proper documentation:
这又如何呢?
What about this?
您可以查看以下文件夹以获取可能的后端列表......
You could look at the following folder for a list of possible backends...