2

I'm using julia and gadfly to draw some plots on a remote server (connected through Putty) and the plots are supposed to open in my default server. They open in lynx, and so don't look like anything really. I'm presuming lynx is the default browser on my work server, and I was wondering whether there is any way to open them in chrome or firefox? I'm not the server administrator and have no permission to use all commands (ie sudo etc).

When trying to use xdg-utils I get an error saying "command not found" and I don't have any applications in my /usr/.local/applications nor could I find a mimeapps.list in the directory.

Is there anything I can do to open these plots in another internet browser instead of lynx? Thank you!

  • I personally am a fan of PyPlot for Julia for the very reason that it doesn't have the annoying dependency on a browser that Gadfly does. – Michael Ohlrogge Jun 27 '16 at 13:23

1 Answers1

2

The order of preferences

Gadfly plots on Julia's display if it can (for example if you're using an interactive graphical notebook with Jupyter).

If there's no suitable way to render on the REPLDisplay, Gadfly will save the plot into a file, then trigger some platform-specific "open this file" logic.

Julia's own display

This is almost certainly the best option. If you run your Julia code in an environment that knows how to display your plots (such as an interactive graphical notebook with Jupyter), then there's nothing more to do.

If you must run your Julia code from a text prompt, you can use a text-based backend renderer, or deal with the fallback process.

xdg-open

Gadfly's fallback display code uses xdg-open to display plot files on Linux-based systems.

The xdg-open tool is part of a package called xdg-utils. The xdg-utils package contains several commands, but xdg-utils is not itself a command -- that's why trying to run "xdg-utils" fails with "command not found".

xdg-open has its own chain of opening things: it will try the opening procedures specific to GNOME, KDE, or whatever desktop environment you're using. It falls back to something called "perl-shared-mimeinfo".

Another tool in the xdg-utils package is xdg-mime, which can query the current file associations as well as change them. You need administrator privileges to change system-wide associations, but you don't need any special permissions to add your own per-user associations.

Since Gadfly is writing to a file then asking xdg-open to open the file, you'll need to handle the filetype (rather than "browser" or URL handler). It might look something like this for HTML files:

$ xdg-mime default mybrowser.desktop text/html

Which computer runs the browser?

Now, you mention that you're using SSH and PuTTY to connect to this server. PuTTY provides a text-based interface to your server -- even if the server had a graphical browser like Firefox installed on it, PuTTY couldn't display it. (You'd need something else on your computer that the server could use to draw the browser window.)

It would probably be more comfortable to use your computer's own browser.

So what do I do?

Launching a browser is a bit weird for a server computer anyway, and it can be fiddly to make it happen. So my recommendation would be either:

  • Skip PuTTY, display directly in a Jupyter notebook.
  • Save your output as HTML (or SVGJS) somewhere that your computer's browser can access it.
RJHunter
  • 2,829
  • 3
  • 25
  • 30
  • Thank you RJ, I set `BROWSER=echo` in terminal and launched julia from path, using Gadfly I tried plotting `plot([sin,cos], 0, 25)` and it still opened it in lynx. Is this due to julia environment variables? I googled around to see if there's a browser variable in julia I could set to `echo`, but found nothing. At the moment I'm silencing the output of the plot function with `;` and saving the plot as a PNG, which seems to work alright, but the pictures are not interactive. I could save them as js.svg as well, but they're slow with this much data. – Ippa Seppälä Jun 28 '16 at 07:32
  • 1
    I've done a bit of research and it seems my advice is off-base: Gadfly is *not* one of the applications that respects `$BROWSER`. It always uses xdg-open (or an equivalent on other platforms), and always uses a filename (not a URL). I'll update my answer shortly. – RJHunter Jun 28 '16 at 11:08