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

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

问题描述

我有一个python代码在名为A的远程计算机上进行一些计算.我通过ssh从A的计算机连接到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天全站免登陆