3 Answers
3

Heike's code produces a graphics output. So if you run it inside a raw kernel (which is what the math command does on linux), it won't display any graphics. Instead you'll see something like --Graphics-- on your screen. To actually display the output, you'll need to load the JavaGraphics package as <<JavaGraphics` before the plot command (this needs to be done only once per session).

When using JavaGraphics`, graphics are rendered by a child front end and converted to a bitmap format. So most new features of graphics are supported. The exception is that if there are interactive aspects to the graphic (tooltips, mouse-overs, Dynamics), they will effectively be ignored. Visualization functions sometimes have problems since in order for them to work correctly, they have to handle Show and DisplayFunction just right. If you do run across problems with a visualization function when using JavaGraphics` , please file it as a bug.

As for the rest of the questions, I'll refer you to the official documentation that Sjoerd shared, as there is no need to duplicate information.

I think if one needs to work with the terminal, to see graphics one could Export them to png and use any image viewer.
–
FJRAMar 14 '12 at 0:17

2

That warning is not accurate. When using JavaGraphics` graphics are rendered by a child front end and converted to a bitmap format. So most new features of graphics are supported. The exception is that if there are interactive aspects to the graphic (tooltips, mouse-overs, Dynamics), they will effectively be ignored. Visualization functions sometimes have problems since in order for them to work correctly, they have to handle Show and DisplayFunction just right. If you do run across problems with a visualization function when using JavaGraphics` , please file it as a bug.
–
Brett ChampionMar 14 '12 at 3:21

@R.M Thanks for pointing out that JavaGraphics` now supports all version 8 graphics. I must have tested it on version 7 when I saw that there were missing features. I've changed my statement on the web page you linked.
–
JensApr 3 '12 at 15:13

@Jens Brett deserves the credit for that (I think it was also discussed in chat by a few people). My apologies — I should've pinged you to let you know that it has changed :)
–
rm -rf♦Apr 3 '12 at 15:19

When you see Mathematica for the first time you try to fit it into the mental model of how software works. While doing that, one of the first things people do is to try to classify Mathematica as a GUI program or as a command line program. Mathematica is unique in that it is both at the same time. For example, commands can take graphics as arguments.

Mathematica has two separate components: The Kernel and the Front End. When you run Mathematica inside a terminal window you are only running the kernel. The kernel let's you do any calculation but you will be lacking the interactive features.

Thanks! Isn't Matlab the same way as you described?
–
TimMar 14 '12 at 14:11

@Tim, Mathematica does not have a MATLAB like GUI, with windows showing files in the current directory or local variables. Most of the stuff, like plotting, happens inside the notebook, and not in separate windows like in MATLAB.
–
AdalMar 14 '12 at 20:09

@Tim does Matlab allow you to copy and paste a graphic directly into a function as an argument?
–
Mr.Wizard♦Mar 15 '12 at 10:02

@Mr.Wizard: I think every graph in matlab has a handle, so it is possible to process that handle. Is it?
–
TimMar 15 '12 at 10:51

@Tim sorry, I don't use Matlab; I was curious myself.
–
Mr.Wizard♦Mar 15 '12 at 11:04

You can start a standalone kernel which pretty much behaves like a very rudimentary command line window. The normal FrontEnd (the "notebook interface") is an extra program which basically is the standard editor but also allows to send pieces of code to an (or several) connected kernels. For the communication these two programs actually don't use the command line interface you see when starting a standalone kernel but a more structured protocol called MathLink.

A notebook file opened in the FrontEnd (= the notebook interface) behaves very similar to a matlab script file with cell mode enabled, where you also can send the code within a "cell" to the kernel. The main difference is that the output will be shown in the command line window (and needs to be saved in an extra file if you want to keep it) in matlab but will be shown in the notebook right below the evaluated cell in Mathematica and become part of that notebook file. Another big difference is that the Mathematica FrontEnd is really a standalone program and you can quit the kernel and start another one from within the FrontEnd, whereas to restart the "matlab kernel" you'll need to restart the matlab graphical user interface.

Especially when you edit .m-package files (not the .nb-notebook files) with the frontend what it does technically is very similar to the matlab editor: in both cases there is some "markup" code inserted into the text file which the editor uses to structure and format the text to show. The notebook file format is somewhat more involved and has AFAIK no real counterpart in matlab, what probably comes closest (but not really) are the matlab "notebook files" which can be used to prepare your matlab code for publishing with html- and latex-formatted comments, but a Mathematica notebook is like a WYSIWYG version of that which will additionally allows for interactive content (see Manipulate and Dynamic).

By using the comand line interface or the mathlink protocol (along with some of the higher level variants like JLink or NETLink) there are in fact infinitely many possibilities to run Mathematica code, there is e.g. a Mathematica mode for emacs or webMathematica, which lets you embedded Mathematica code in html to be executed on a webserver. If you are looking for an interface that is more like what you are used to from matlab you could also have a look at Wolfram Workbench, which is basically a Mathematica plugin for the eclipse IDE.

But I think especially for a beginner it is much better to get familiar with the normal notebook interface, otherwise you'll stumble across peculiarites like the graphics output every now and then. Just because the notebook interface is different from what you have seen before doesn't mean it's bad: in fact I think that for a great many use cases the concept of the notebook interface has big advantages and only by making use of these you'll get the most out of Mathematica's possibilities. If you don't engage in the "Mathematica way" and use it just like matlab with a different syntax you can't expect to gain very much except of wondering about oddities.

A different interface (like the workbench or the command line interface) only seems to make sense when you have very special demands, e.g. you are writing more involved packages for others to use or you need to run large jobs using a job queuing/scheduling system.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.