Mathematica 9 is now available
6.11 Displaying Mathematics and Graphics

Documentation6. Advanced Topics

 

6.11 Displaying Mathematics and Graphics

In order to display typeset mathematics and graphics, the server can generate images. These provide a simple way to view the results of computations. However, they suffer from the serious defect that they cannot be used by the client. They cannot be resized, drawn with different fonts, or viewed in some alternative way. It is also hard for a computer program to extract any meaning from an image. Alternatives to images exist. In the case of mathematics one can use MathML, for graphics one can use SVG, and an applet can be deployed for three-dimensional graphics. These alternatives are not always the appropriate solution and, for this reason, functions for generating images are provided.

When a Mathematica kernel generates an image, it is stored in a file on the server and adds a reference in the HTML file that is returned. For example, the following img element may be generated.

<img src="/webMathematica/MSP?MSPStoreID=MSPStore1042942578_0&amp;MSPStoreType=image/gif" alt="Created by webMathematica"/>

The SRC attribute references the MSP servlet through a URL, which includes a parameter that gives the name of the file. The MSP servlet returns the contents of the file and periodically deletes old image files. The actual location in which image files are saved is a workspace directory provided by the servlet container.

More information about generating images can be found in the Mathematica Function Reference section, especially under MSPFormat, MSPShow, and MSPShowAnimation.

An alternative way to generate images is to use the Mathematica command Export, available for use with the function MSPExportImage. This provides more features, such as transparent backgrounds, but takes longer to generate. MSPExportImage always makes use of the Mathematica front end.

MSP Functions Returning Images

There are various MSP functions that return images: MSPShow, MSPShowAnimation, and MSPExportImage; in addition MSPFormat may return an image. The workings of these commands are detailed in the Mathematica Function Reference section. It should be noted that these all work by returning a string that contains the necessary img tag to reference the image file which is stored on the server. An example is shown below.

<msp:evaluate>
   MSPShow[ graphics]
</msp:evaluate>

Therefore, if the MSP function is followed by a semi-colon ';', as shown below, this will suppress the output. The use of a semi-colon to suppress output is discussed in the section on Evaluation Formatting.

<msp:evaluate>
   MSPShow[ graphics];
</msp:evaluate>

Another use of these functions is to embed their results into some other formatting function such as those in the HTML Package. The example below will return an HTML table with two images.

<msp:evaluate>
   Needs["MSP`HTML`"]
</msp:evaluate>

<msp:evaluate>
   HTMLTableForm[ {MSPShow[ g1], MSPShow[ g2]}]
</msp:evaluate>



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. CURRENT WEBMATHEMATICA DOCUMENTATION IS NOW AVAILABLE.