|On this page…|
This section describes some common problems you might encounter when printing or exporting your figure. If you don't find your problem listed here, try searching the Knowledge Base maintained by MathWorks® Technical Support Department. Go to http://www.mathworks.com/support and enter a topic in the search field.
Try one of the following solutions:
Check the table of drivers in the print reference page to see if there are other drivers you can try.
If your printer is PostScript®-compatible, try printing with one of the MATLAB® built-in PostScript drivers.
If your printer is not PostScript-compatible, see if one of the MATLAB built-in Ghostscript devices is appropriate for your printer model. These devices use Ghostscript to convert PostScript files into other formats, such as HP® LaserJet and Canon® BubbleJet.
Contact the printer vendor to obtain a different native printer driver. The behavior you are experiencing might occur only with certain versions of the native printer driver. If this doesn't help and you are on a Windows system, try reinstalling the drivers that were shipped with your Windows installation disk.
Export the figure to a graphics-format file, and then import it into another application before printing it. For information about exporting MATLAB figures, see Exporting to a File.
When I use the print function with the -deps switch, I receive this error message.
Encapsulated PostScript files cannot be sent to the printer. File saved to disk under name 'figure2.eps'
As the error message indicates, your figure was saved to a file. EPS is a graphics file format and cannot be sent to a printer using a printer driver. To send your figure directly to a printer, try using one of the PostScript driver switches. See the table of drivers in the print reference page. To print an EPS file, you must first import it into a word processor or other software program.
You can set the default value for any property by adding a line to startup.m. Adding the following line sets the default paper type to A4.
set(0, 'DefaultFigurePaperType', 'A4');
In your call to set, combine the word Default with the name of the object Figure and the property name PaperType.
I set the paper orientation to landscape, but each time I go to print a new figure, the orientation setting is portrait again. How can I change the default orientation so that I won't have to set it for each new figure?
See the explanation for the previous question. Adding the following line to startup.m sets the default paper orientation to landscape.
set(0, 'DefaultFigurePaperOrient', 'landscape')
You must be using a color printer driver. You can specify a black-and-white driver using the print function or the Print Preview dialog box to force the lines for the current figure to print in black. See Setting the Line and Text Color for instructions.
There are two things that can cause this to happen. Most likely, the line is positioned over a dark background. The MATLAB default is to invert your background to white when you print, and changes any white lines over the background to black. To avoid this, retain your background color when you print. See Setting the Background Color.
The other possibility is that you are using a Windows printer driver and the printer is sending inaccurate color information to MATLAB.
By default, MATLAB uses a black-and-white printer driver. You need to specify a color printer driver. For instructions, see Choosing a Printer Driver. If you are already using a Windows color driver, the printer might be returning inaccurate information about its color property. See Driver-Specific Information.
You can use either the Print dialog box, or the MATLAB print function, specifying the printer with the -P switch. For instructions using either method, see Selecting the Printer.
You are probably using bitmapped fonts, which don't rotate well. Try using TrueType fonts instead.
By default, MATLAB resizes your figure when converting it to printer coordinates. That means it calls any ResizeFcn you have created for the figure and issues a warning. You can avoid this warning by setting the figure to print at screen size.
I get the following error message on my LINUX/UNIX system ‘Printing failure. There are no properly configured printers on the system.'
This might be a problem with the location of the lpc command on your system. If not present, create a symbolic link from /usr/sbin/lpc to wherever the lpc command resides on your system.
I generated a figure with a black background and selected "Use figure color" from the Copy Options panel of the Preferences dialog box. But when I exported my figure, its background was changed to white.
You must have exported your figure to a file. The settings in Copy Options only apply to figures copied to the clipboard.
There are two ways to retain the displayed background color: use the Print Preview dialog box or set the InvertHardCopy property to off. See Setting the Background Color for instructions on either method.
You can set the default value for any property by adding a line to startup.m. Adding the following line sets the default figure size to 4-by-3 inches.
set(0, 'DefaultFigurePaperPosition', [0 0 4 3]);
In your call to set, combine the word Default with the name of the object Figure and the property name PaperPosition.
On Windows systems, use the Copy Options panel of the Preferences dialog box. Any settings made here, including whether your figure is copied as a metafile or bitmap, apply to all copy operations. See Exporting to the Windows or Macintosh Clipboard for instructions.
I exported my figure to an EPS file, and then tried to import it into my Word document. My printout has an empty frame with an error message saying that my EPS picture was not saved with a preview and will only print to a PostScript printer. How do I include a TIFF preview?
Use the print command with the -tiff switch. For example,
print -deps -tiff filename
If you print to a non-PostScript printer with Word, the preview image is used for printing. This is a low-resolution image that lacks the quality of an EPS graphic. For more information about preview images and other aspects of EPS files, see EPS Files.
You must have used a bitmap format. Bitmap files generally do not resize well. If you are going to export using a bitmap format, try to set the figure's size while it's still in MATLAB. See Setting the Figure Size and Position for instructions.
As an alternative, you can use one of the vector formats, EMF or EPS. Figures exported in these formats can be resized in Word without affecting quality.
This problem occurs with some Microsoft® Word and Windows versions. Try editing the labels in Word.
There are two likely causes: you used the print function and forgot to specify the export format, or your word processing program does not support the export format. Include a format switch when you use the print function; simply including the file extension is not sufficient. For instructions, see Exporting to a File.
If this does not solve your problem, check what formats the word processor supports.
You cannot append figures to an EPS file. The -append option is only valid for PostScript files, which should not be confused with EPS files. PostScript is a printer driver; EPS is a graphics file format.
Of the supported export formats, only HDF supports storing multiple figures, but you must use the imwrite function to append them. For an example, see the reference page for imwrite.
Your graphics have probably become complicated enough that MATLAB is using the OpenGL® or Z-buffer renderer instead of the Painter's renderer. It does this to improve display time or to handle attributes that Painter's cannot, such as lighting. However, using OpenGL or Z-buffer causes a bitmap to be stored in your EPS file, which with large figures leads to a large file.
There are two ways to fix the problem. You can specify the Painter's renderer when you export to EPS, or you can use a bitmap format, such as TIFF. The best renderer and type of format to use depend upon the figure. See Choosing Bitmap or Vector Graphic Output if you need help deciding. For information about the rendering methods and how to set them, see Selecting a Renderer.
Use getframe to capture the frames, imwrite to write them to a file, and movie to create a movie from the files. For more information about using getframe and imwrite to capture and write the frames, see Exporting with getframe. For more information about creating a movie from the captured frames, see the reference page for movie.
You can also save multiple figures to an AVI file. AVI files can be used for animated sequences that do not need MATLAB to run. However, they do require an AVI viewer. For more information, see Export to Audio and Video in the MATLAB Programming Fundamentals documentation.
You need to use the print function to do any of the following operations:
Export to a supported file format not listed in the Export dialog box. The formats not available from the Export dialog box include HDF, some variations of BMP and PCX, and the raw data versions of PBM, PGM, and PPM.
Specify a resolution.
Specify one of the following options:
Loose bounding box for EPS files
Compression quality for JPEG files
CMYK output on Windows platforms
Perform batch exporting.
By default, when you print or export a figure, the background color inverts to white. There are two ways to retain the displayed background color: use the Print Preview dialog box or set the InvertHardCopy property to off. See Setting the Background Color for instructions on either method.
If you are exporting your figure to the clipboard, you can also use the Copy Options panel of the Preferences dialog box. Setting the background here sets it for all figures copied to the clipboard.
You can set the default value for any property by adding a line to startup.m. As an example, the following line sets the default axes label font size to 12.
set(0, 'DefaultAxesFontSize', 12);
In your call to set, combine the word Default with the name of the object Axes and the property name FontSize.
Check your settings for figure size and resolution, both of which affect the output dimensions of your figure.
The default figure size is 8-by-6 inches. You can use the Print Preview dialog box or the PaperPosition property to set the figure size. See Setting the Figure Size and Position.
The default resolution depends on the export format or printer driver used. For example, built-in MATLAB bitmap formats, like TIFF, have a default resolution of 150 dpi. You can change the resolution by using the print function and the -r switch. For default resolution values and instructions on how to change them, see Setting the Resolution.
You probably output your figure using a higher resolution than your screen uses. Set your resolution to be the same as the screen's.
As an alternative, if you are exporting your figure, see if your application enables you to select a resolution. If so, import the figure at the same resolution it was exported with. For more information about resolution and how to set it when exporting, see Setting the Resolution.
Your figure size might be too small to accommodate the labels. Labels are positioned a fixed distance from the x-axis. Since the x-axis itself is positioned a relative distance away from the window's edge, the label text might not fit. Try using a larger figure size or smaller fonts. For instructions on setting the size of your figure, see Setting the Figure Size and Position. For information about setting font size, see the Text Properties reference page.
MATLAB has rescaled your ticks because the size of your output figure is different from its displayed size. There are two ways to prevent this: select Keep screen limits and ticks from the Advanced tab of the Print Preview dialog box, or set the XTickMode, YTickMode, and ZTickMode properties to manual. See Setting the Axes Ticks and Limits for details.
Use the print function with the -noui switch. For details, see Excluding User Interface Controls from Printed Output.
Only PostScript printer drivers and the EPS export format support uncropped output. There is a workaround for Windows printer drivers, however. Using the print function, save your figure to a file that can be printed later. For an example see Producing Uncropped Figures.
You have probably used a font that is not supported by EPS and PostScript. All unsupported fonts are converted to Courier. See PostScript and Ghostscript Supported Fonts for the list of the supported fonts.