简体   繁体   中英

Graphics in command-line Mathematica 7?

How do I make command-line Mathematica 7 display graphics?

In older versions of Mathematica, "Plot[x,{x,1,2}]" would popup a window displaying the plot w/ some formatting options (line thickness, equal xy scaling, etc).

Mathematica 6 and up don't do this. According to http://pages.uoregon.edu/noeckel/Mathematica.html most of the graphics code is now in the notebook interface, not the command-line interface.

The page above also suggests "<<JavaGraphicsX" as a hack (where X is the backtick character which I can't seem to enter here). This works, but the graphics window has no options, and, when I resize the window, the graph doesn't resize.

Is there a better solution?

My attempt to load Motif.m sadly fails:

In[1]:= <<Motif` 

StringForm::sfr:  
   Item 0 requested in "The Motif` graphics package is obsolete, loading 
      JavaGraphics`." out of range; 0 items available. 
Motif::obslt: The Motif` graphics package is obsolete, loading JavaGraphics`. 
 -- Java graphics initialized --  

Following Debugging a working program on Mathematica 5 with Mathematica 7 I tried loading Version5`Graphics but that didn't really help either.

In[1]:= << Version5`Graphics` 
 -- PostScript to stdout graphics initialized --  

In[2]:= Plot[x,{x,1,2}] 
%! 
%%Creator: Mathematica 
%%AspectRatio: .61803 
MathPictureStart 
/Mabs {  
Mgmatrix idtransform 
Mtmatrix dtransform 
} bind def 

[bunch of Postscript crap] 

% End of Graphics 
MathPictureEnd 

Out[2]= -Graphics- 

If you are ok with getting the graphics as files instead of pop-up windows, you can use Export :

SetDirectory[NotebookDirectory[]]    
gfx = Plot[Sin[x], {x, 0, 3}];
Export["sinplot.pdf", gfx]

You should of course replace NotebookDirectory with something that makes sense outside the notebook context. You can use Show to combine Graphics objects, set ranges and viewpoints, etc.

Currently, you need to specify java grahics:

 <<JavaGraphics`
 Plot[PLOT OPTIONS]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM