views:

36

answers:

2

Hi, 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?

+2  A: 

Sure, you can enable X11 forwarding. Usually this is done by passing the -X or -Y option to ssh when you connect to the remote computer

ssh -X computerA

Note that the SSH daemon on computer A will also have to be configured to enable X11 forwarding. This is done by putting

X11Forwarding yes

in computer A's sshd_config configuration file.

If computer A's SSH daemon does not have X11 forwarding enabled, you can always have Python write the result of the calculation to a text file, download it to computer B, and use Matplotlib locally.

David Zaslavsky
thanks, but where is the sshd_config?
Mermoz
update: it's in /etc/sshd_config
Mermoz
+1  A: 

If you use matplotlib on Mac OS X, 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. Selecting a back-end can be achieved with

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

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 forwarding can then be used to display matplotlib plots.

EOL