Is there an easy way to get Mathematica graphics into a sage notebook?
I have a notebook where I want to compare the Mathematica way of doing things and the related graphics to the sage way and its graphics. The naive ways of doing it do not work:
%mathematica
Plot[Sin[x],{x,-4,4}]
just produces
-Graphics-
While
mathematica('Plot[Sin[x],{x,-4,4}]')
returns the InputForm
of the graphics, i.e.,
Graphics[{{{}, {}, {Hue[0.67, 0.6, 0.6], Line[{<<long list of points>>}],
<<some graphics options>>]
There's three work-arounds I can currently think of.
Export the graphics from Mathematica using:
Export["file.png", graphics]
and import it back into sage - but I couldn't find an image import function in sage...Use the JavaGraphics Mathematica package: So
but this puts the graphics object in a separate window (not in the sage notebook).
Extract the graphics data and feed it into a sage plotting function, e.g.
list_plot(mathematica('Plot[Sin[x], {x, -4, 4}][[1, 1, 3, 2, 1]]').sage(), plotjoined = true)
which does what I want, but is a little cumbersome - especially for more complicated graphics.