matplotlib plotting on remote machine

I log into mac (M4) using ssh (with X11) and want to make a plot to show on the remote machine (from which I log in) but the plot only shows up on the local machine running python. I set up tkagg, and xterm, xclock, ... al show windows on the remote machine, but matplotlib plots don't. Seems to be an issue that tcl/tk ignores the DISPLAY environment variable. I installed it using homebrew.

Mac mini, macOS 15.3

Posted on Mar 22, 2025 4:10 AM

Reply
3 replies
Sort By: 

Mar 22, 2025 5:18 AM in response to 2sn

macOS is NOT X11 based.


Yes, you can install XQuartz, but then ONLY programs explicitly written to use X11, such as xterm, xclock, xeyes, etc… will actually send their windows to the X11 display server.


Python, installed on macOS, is not X11 based, so it is not going to open remote X11 windows for its output.


If the remote machine is another Mac, then macOS Screen Sharing is how you can see the plot.


If a Linux/Unix based system, then VNC. It is possible to configure System Settings-> General-> Sharing-> Screen Sharing to have a VNC password, and allow VNC clients to connect.


If VNC security is important, when you make your ssh connection, create a VNC tunnel


ssh -L 5922:localhost:5900 the.Macs.addr


And on your Linux/Unix system connect your VNC client to localhost:5922


TigerVNC is the VNC client we use at work, although our use is mostly from Macs to Linux/Unix development systems, but TigerVNC is available for the *nix based systems.


Mac-to-Mac Screen Sharing is already an encrypted connection.

Reply

Mar 22, 2025 9:31 PM in response to BobHarris

@BobHarris

thank you for your swift reply and the suggested workarounds.


As there are other tools (xterm, xclock, ... ) that are based on X11 that work, I see no fundamental reason why there could not be a tcl/tk or tkinter version for MacOS that uses X11 as well - both on Mac and remotely.

(We sue that, e.g., for some custom X11 application, and it works fine there.)


Please let me know if you become aware of any such library and implementation. Or, maybe there are some settings one could use for that.

Reply

Mar 23, 2025 6:27 AM in response to 2sn

If you can compile the Linux version of some programs that are X11 based, they should work.


You might find some X11 based programs in Homebrew https://brew.sh


But most open source programs that are ported to macOS, substitute different display packages, that are macOS based and not X11.


While an interesting exercise, you would save yourself a lot of grief by just using VNC for any non-terminal emulator graphics output.

Reply

matplotlib plotting on remote machine

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.