Matplotlib:在远程机器上显示绘图 [英] Matplotlib: display plot on a remote machine

查看:52
本文介绍了Matplotlib:在远程机器上显示绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Python 代码在名为 A 的远程机器上进行一些计算.我通过 ssh 从名为 B 的机器连接到 A.有没有办法在机器B上显示图形?

I have a python code doing some calculation on a remote machine, named A. I connect on A via ssh from a machine named B. Is there a way to display the figure on machine B?

推荐答案

如果您在远程计算机 (B) 上的 Mac OS X 上使用 matplotlib,则必须首先确保您使用的是基于 X11 的显示器之一 -结束,因为本机 Mac OS X 后端无法将其绘图导出到另一个显示器.选择后端可以通过

If you use matplotlib on Mac OS X on the remote machine (B), you must first make sure that you use one of the X11-based display back-ends, since the native Mac OS X back-end cannot export its plots to another display. Selecting a back-end can be achieved with

import matplotlib
matplotlib.use('GTK')  # Or any other X11 back-end

支持的后端列表可以通过给 use() 一个不正确的后端名称获得:matplotlib 然后打印一条错误消息,列出可能的后端.

The list of supported back-ends can be obtained by giving use() an incorrect back-end name: matplotlib then prints an error message listing the possible back-ends.

然后可以使用 ssh X11 转发来显示 matplotlib 图.

ssh X11 forwarding can then be used to display matplotlib plots.

这篇关于Matplotlib:在远程机器上显示绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆