File name to plot into
The attribute OutputFile allows to specify a file name to direct the plot output into an external file instead of rendering the plot on the screen. The extension of the file name indicates the export format.
The available formats include .xvz and .xvc (the MuPAD® proprietary XML format) as well as various standard bitmap formats such as .bmp, .gif, .jpg etc. and vector formats such as.eps, .svg etc. Animated MuPAD graphics can be exported to animated GIF files. On Windows® systems, it also can be exported to .avi format.
Some of the export formats allow to specify certain parameters such as "resolution," "quality" etc. Such parameters may be specified by the attribute OutputOptions.
plot(..graphical objects.., OutputFile = "mypicture.xvz"):
(Here, the extension .xvz of the file name "mypicture.xvz" indicates that the MuPAD XML data are to be written).
If the MuPAD environment variable WRITEPATH does not have a value, the previous call creates the file in the directory where MuPAD is running. (On Windows and Macintosh systems, this is, by default, the directory where it is installed).
After setting WRITEPATH to the absolute path of a folder, the file is created in that folder. For example, after
WRITEPATH := "C:\\Documents":
plot(..graphical objects.., OutputFile = "mypicture.xvz"):
stores the plot data in the file "C:\Documents\mypicture.xvz." Alternatively, the file name can be specified as an absolute pathname:
plot(..objects.., OutputFile = "C:\\Documents\\mypicture.xvz"):
If a MuPAD notebook was saved to a file, its location is available inside the notebook as the environment variable NOTEBOOKPATH. If you wish to save your plot in the same folder as the notebook, you may call
plot(..objects.., OutputFile = NOTEBOOKPATH."mypicture.xvz"):
The plot data can be stored in various formats indicated by the extension of the file name. In particular, there are the MuPAD proprietary XML formats. The file extension .xvz indicates that XML data are to be written and, finally, the file is to be compressed. Alternatively, the extension .xvc may be used to write the XML data without final compression (the resulting text file can be read with any text editor). Files in both formats can be inserted into a MuPAD notebook and freely manipulated.
Apart from saving files as XML data, MuPAD pictures can also be saved in a variety of standard bitmap formats such as .bmp, .gif, .jpg etc. Also .svg and .eps export is available. Just use an appropriate extension of the file name indicating the format.
Note: Only XML files .xvz and .xvc retain the information necessary for interactive manipulation in a MuPAD notebook. All other formats are intended for exporting graphics to other programs.
If no file extension is specified in the file name, the default extension .xvz is used, i.e., XML data are written.
On Windows systems, animated MuPAD plots can be exported to .avi format. Cf. Example 2.
In addition to OutputFile, there is the attribute OutputOptions to specify parameters for some of the export formats. The admissible value for this attribute is a list of equations:
OutputOptions = [<ReduceTo256Colors = b >, <DotsPerInch = n1>, <Quality = n2>, <JPEGMode = n3>, <EPSMode = n4>, <AVIMode = n5>, <WMFMode = n6>, <FramesPerSecond = n7>, <PlotAt = l1>]
Each entry of the list is optional. The parameters are
|b||TRUE or FALSE. Has an effect for export to some raster formats only. With TRUE, only 256 different colors are stored in the raster file. The default value is FALSE.|
|n1||Positive integer setting the resolution in DPI (dots per inch). Has an effect for export to raster formats only. The default value depends on the hardware.|
|n2||One of the integers 1, 2, …, 100. This integer represents a percentage value determining the quality of the export. Has an effect for JPG, 3D EPS, 3D WMF and AVI export only. The default value is 75.|
|n3||0, 1, or 2. Has an effect for JPG export only. The flag 0 represents the JPG mode `Baseline Sequential', 1 represents `Progressive', 2 represents `Sequential Optimized'. The default value is 0.|
|n4||0 or 1. Has an effect for EPS export only. The flag 0 represents the EPS mode `Painter's Algorithm', 1 represents `BSP Tree Algorithm'. The default value is 0.|
|n5||0, 1 or 2. Has an effect for AVI export only. With 0, the `Microsoft® Video 1 Codec' is used. With 1, the `Uncompressed Single Frame Codec' is used. With 2, the `Radius Cinepak Codec' is used. The default value is 0.|
|n6||0, 1 or 2. Has an effect for WMF export only. With 0, the `Painter's Algorithm' is used. With 1, the `BSP Tree Algorithm' is used. With 2, a `embedded bitmap' is created. The default value is 0.|
|n7||Positive integer setting the frames per second for the AVI to be generated. Has an effect for AVI and animated GIF export only. The default value is 15.|
|l1||List of real values between TimeBegin and TimeEnd which determines the times at which pictures should be saved from an animation.|
The following commands save the plot in four different files in JPG, EPS, SVG, and BMP format, respectively:
f1 := plot::Function2d(sin(x), x = 0..PI, Color = RGB::Red): f2 := plot::Function2d(cos(x), x = 0..PI, Color = RGB::Blue): plot(f1, f2, OutputFile = "mypicture.jpg"): plot(f1, f2, OutputFile = "mypicture.eps"): plot(f1, f2, OutputFile = "mypicture.svg"): plot(f1, f2, OutputFile = "mypicture.bmp"):
If no file extension is specified in the file name, the default extension .xvz is used, i.e., XML data are written. The following command creates the file mypicture.xvz:
plot(f1, f2, OutputFile = "mypicture"):
An animated MuPAD plot can be exported to .avi format:
plotfunc2d(sin(x - a), x = 0 .. 2*PI, a = 0 .. 5, OutputFile = "myanimation.avi"):
An animated MuPAD plot can be exported to serveral single images at given times:
plotfunc2d(sin(x - a), x = 0 .. 2*PI, a = 0 .. 5, OutputFile = "someName.png", OutputOptions=[PlotAt = [i $ i = 0..10 step 0.5]]):