Exporting graphics from the Mathematica Language on Raspberry Pi

The only way I can figure out to see graphics generated in the Mathematica language is to export them and then view them using ImageViewer.
Is there another way?

If you are running “mathematica” instead of ‘wolfram’ then you get an interactive session that displays the graphics. This assumes that you are running X.

“Wolfram” is a fair amount faster than Mathematica on the Raspberry Pi, possibly due to the overhead from the notebook interface.

Frank,

If you prefer running in the shell with using the ‘wolfram’ command, then you can launch the image viewer also from within the WL like so:

p = Plot[ Sin[x], {x,0,1} ];
Export["test.png",p];
Run["gpicview test.png &"];

Or if you want to open it in Midori (default browser on Raspbian), then you can change the Run command to use that:

Run["midori test.png &"]

Frank,

Another possibility that just occurred to me, is to set the $DisplayFunction to do the Export/Run command automatically:

$DisplayFunction = Function[{g},
  Module[{t},
    t=CreateTemporary[];
    Export[t,g,"PNG"];
    Run["gpicview "<>t<> " &"]
  ]
]

Now all your plots will open in their own Image Viewer window.

Thanks, Arnoud, I’ll try out your suggestions.

Just for completeness, $DisplayFunction has no effect on Image[] but you can use Format to change
the formatting of Image so that it outputs to an external viewer:

Unprotect[Image];
Format[i:_Image,OutputForm] := Module[{t},
  t=CreateTemporary[];
  Export[t,i,"JPG"];
  Run["gpicview "<>t<>" &"]
];

Arnoud, just now trying this trick out. Redirecting $DisplayFunction works like a charm, and is very helpful when I remote SSH into my RPi and want to perform graphics-related actions.