Message Boards Message Boards

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?
POSTED BY: Frank Kampas
7 Replies
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.  
POSTED BY: BoB LeSuer
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<>" &"]
];
POSTED BY: Arnoud Buzing
Thanks, Arnoud, I'll try out your suggestions.
POSTED BY: Frank Kampas
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.
POSTED BY: Arnoud Buzing
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 &"]
POSTED BY: Arnoud Buzing
"Wolfram" is a fair amount faster than Mathematica on the Raspberry Pi, possibly due to the overhead from the notebook interface.
POSTED BY: Frank Kampas
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.
POSTED BY: BoB LeSuer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract