Search Comments and Ratings

go

Comments and Ratings

   
Date File Comment by Comment Rating
22 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Haesevoets, Yvonne

...and how do you preserve the line style in tiff files e.g.? Thanks again!

22 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Haesevoets, Yvonne

Absolutely awesome!! If only I had found this sooner!! Thanks for sharing!
How can I increase the resolution? The -m option increases the file size, not the resolution.

20 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Bob

Oliver, thanks very much but something is funny. If I have the property editor open for the original figure the color is white. I run the set commands and the color is none. I then use export_fig and the color goes back to white (as seen in the Property Manager), and the figure has a white background (export_fig foo.png -pdf; OS X 10.6.2, 2009b). Same white background on the pdf and the png.

20 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Woodford, Oliver

Bob:
set(gcf, 'color', 'none'); % Set the figure background to transparent
set(gca, 'color', 'none'); % Set the axes background to transparent

20 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Bob

Wish I had found this great script sooner!

Can someone tell me how to set the color property to 'none'. If you set edit figure and then use the property editor you only get an option for color (e.g. a palette), you can't type in 'none'. I'm missing something obvious here, can someone please help me with this.

20 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Bob

18 Nov 2009 real2rgb & colormaps Converts intensity matrices into truecolor images. Author: Oliver Woodford Woodford, Oliver

Richard: This issue is do do with the way MATLAB deals with the colormap, rather than the colormap itself, which is as it should be. MATLAB can only handle 256 level colormaps for indexed images (on Windows). Pcolor avoids the problem. So does using truecolor (rather than indexed) images. You can use real2rgb to generate a truecolor image from your 1024 level colormap and your indexed image.

18 Nov 2009 real2rgb & colormaps Converts intensity matrices into truecolor images. Author: Oliver Woodford Richard

Hi Oliver.

I don't understand what happens when a colour map with more than 256 elements is requested. I'm trying to create a jet colour map with 1024 elements to display a 10 bit image using the image function. If I do this using either your version of jet or the Matlab one, I get the same result - all blue! 512 creates blue and green strips. 300 elements gives the normal jet colour map between 0 and 255, then it looks like it starts over again from blue. This is not what I would expect - values lower than 256 correctly fit the full colour range into the number of colour map entries requested - I don't see why this should be any different for larger colour maps.

The work around I'm using is to use pcolor instead of image to plot the data, as this seems to work with a smaller (presumably 256 element) colour map and map the data onto this. While this works, I don't like the pcolor function very much. It's not intended for displaying images. The axes labels align with grid lines instead of pixels, the data cursor selects points instead of pixels, and I need to have an extra row and column of data.

Is there a way of getting a 1024 element colour map that behaves as would be expected?

Thanks!
Richard.

16 Nov 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Stefan

Today the answer of TMW's support team arrived.
They admit that the font support of the print function is limited to a few fonts only up to now.
See http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f3-103191.html#f3-96545

It it not sure if or when this will change.

Thank you Oliver anyway!

I now use Matlab for formatting the figure and the page size. Subsequently I print pdfs using an external pdf printer.

13 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Willis, Keely

My graphics driver was out of date. Since I updated the driver, everything work perfectly. Thanks!

12 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Woodford, Oliver

A reminder for everyone: As I say in the description, please do email me (use the "Contact Author link on my author page) when you have a problem, rather than place it here. I'll respond quicker, and also people finding the function won't think it never works!

12 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Willis, Keely

I'm having trouble printing to png format, the figures come out completely black. I'm using MATLAB version 2008b. The command I'm using is "export_fig filename -png".

Thanks for any advice.

12 Nov 2009 SC - powerful image rendering Useful tool for rendering and outputting information rich images Author: Oliver Woodford Ange

11 Nov 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Richards, Clark

Great script. It's driven me nuts for a long time that outputting to pdf in Matlab is a headache.

It would be useful if there was an 'append' option for the pdf output. I don't always want to append to the end of a file, often I just want to update a figure and have it overwrite whatever was already there.

10 Nov 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Woodford, Oliver

Stefan: For some reason the eps file generated by MATLAB's print function doesn't name the fonts correctly. I suggest you contact TMW's technical support. If and when print generates an eps file correctly but print_pdf/export_fig doesn't then generate the correct pdf, then I will investigate further.

10 Nov 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Stefan

Hi Oliver,

thanks for your reply.
I only use ttf fonts at the moment.

I tried your first suggestion, but nothing changed. I now use the options

options = [options '-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="' dest '" -sFONTPATH="C:/Windows/Fonts"'];

Obviously gs doesn't know the fonts except for the standard ones.

I also tried to set the path:

c:\> SET GS_LIB=c:\windows\fonts

And I tried to add fonts to gs/fonts/fontmap (using FontMap v1.7), e.g. the line

/Coronet (C:/WINDOWS/FONTS/coronet.ttf) ;

But all I can see in the pdf file is this Courier font.

Any other ideas? Did anyone successfully export other fonts to pdf?

Stefan

08 Nov 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Woodford, Oliver

Stefan: Two things might help. Firstly, you need to make Ghostscript knows about the fonts you want to include. You can tell it where to look by using the -sFONTPATH="C:\blah\blah" option (obviously using the right path). Secondly, you need to make sure the fonts are in a format that Ghostscript understands. For example, I don't think it understands the OpenType format.

06 Nov 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Stefan

Hi,

not each font is exported correctly on my system.

Ex:
plot((0:10),sin(0:10));
set(gca,'FontName','Arial Black');
export_fig('test', '-pdf');

The font is not 'Arial Black' in this example, although beeing correctly displayed in Matlab.

I'm using winXP, Matlab 7.8.0 (R2009a), Ghostscript 8.70, Adobe Reader 9.2.0. I tried some other fonts, only 'Arial' seems to work properly.

Is this behavior reproducible on your systems or is a solution available?

Thanks for your help!
Stefan

28 Oct 2009 real2rgb & colormaps Converts intensity matrices into truecolor images. Author: Oliver Woodford Malte

Very handy, worked right away, helped me to superimpose transparent color map on grayscale image. Thanks!

26 Oct 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Woodford, Oliver

Michael: MATLAB's print often does funny things to a plot, such as changing the number of tick marks, when you export it, and I don't know how to avoid it. Export_fig uses print, and therefore unfortunately suffers from the same problem.

20 Oct 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Kitz, Michael

I wanted to use this tool to save a jpg with the borders cropped. Now I realized that the axes settings were changed during export.
I was using a figure with three subplots, two graphs and an image.
The plots were displaying 7000 data points in a customized scale using the whole axes area. Matlab's autoscale uses 8000 points and so did the export function.
Is there a way to avoid the autoscale?

16 Oct 2009 fullpath Generates a full path from a partial or relative path Author: Oliver Woodford Woodford, Oliver

Thanks Julian. To be correct, I should say that every directory except the bottom level file or directory must exist. I.e. only the bottom level directory is allowed to be non-existant.

16 Oct 2009 fullpath Generates a full path from a partial or relative path Author: Oliver Woodford Julian

You say that the directory need not exist but I found this not to be the case when using CD myself a while ago to do much the same thing (but less concise than your nice function). Is this correct?

27 Sep 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Montorsi, Francesco

22 Sep 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Woodford, Oliver

m g: The figure you wish to export must be open. You cannot specify it by the filename. The filename is that of the output file, not the input file.

Erica: The filename should be a string. Just like any other MATLAB function, you can call export_fig using parentheses around the input arguments, or not, in which case the inputs are interpreted as strings; i.e. if one of the inputs is not a string then you must use parentheses. The outputs are not the same as those used by print. Type
   help export_fig
for a full description of usage.

18 Sep 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Alston, Erica

Hi

What is the calling sequence for using this function? should the filename be in parentheses? are the output formats the same as used by matlap e.g. -depsc?

Many thanks!

14 Sep 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford g, m

I am unable to use export_fig on my linux machine
i am using the command
export_fig f.fig -eps
and i get the following error:
'No Figure to Print"
and a Warning /tmp/tmp<long string>.eps not found

please help.
thanks,

12 Aug 2009 SC - powerful image rendering Useful tool for rendering and outputting information rich images Author: Oliver Woodford Woodford, Oliver

Justin - if you prefer the image displaying properties of imagesc I suggest you use image(sc(X)). However, you then don't get the correct colorbar. If it's just the aspect ratio you don't like then call set(gca, 'DataAspectRatioMode', 'auto') after sc.

12 Aug 2009 SC - powerful image rendering Useful tool for rendering and outputting information rich images Author: Oliver Woodford Justin

The autopreservation of aspect ratio (mentioned by http://www.mathworks.com/matlabcentral/fileexchange/authors/27420) is the only thing I don't like about sc If I have a very long narrow matrix, imagesc scales it to display it in a standard sized matlab window. sc on the other hand gives me an extremely long narrow window. If there's an easy way to disable this please let me know.

Otherwise it's great.

31 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Annette

I'm trying to use this function with Matlab r2007b on a Mac (OS 10.5), and I get the error:

??? Error using ==> rdivide
Number of array dimensions must match for binary array op.

Error in ==> export_fig at 143
        A = uint8(B ./ A(:,:,[1 1 1]));

Any insight?

Cheers!

27 Jul 2009 imdisp Display multiple images as a montage of subplots Author: Oliver Woodford Bulatov, Yaroslav

One gotcha is that one image in the grid can be rendered differently depending on other images in the array (related to scaling of intensity values perhaps?)

22 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Mar, Jason

Great function! It saves me a lot of time, thanks!
Wish I could disable cropping more easily though.

20 Jul 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Matthijs

14 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford cartonn

how do you export the image with a greater value of dpi?
-r600 does not work

09 Jul 2009 vol3d v2 3-d volume (voxel) rendering Author: Oliver Woodford Van den Bulcke, Jan

Wonderful!

08 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Sebastiaan

07 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Korsawe, Johannes

Really nice.
I still have a problem using uipanels (guis):

 If i create a plot and a colorbar, the colorbar will not be printed in the result.

Is it possible to enable for a search for colorbars? I tried to adopt your code but failed in copying the correct stuctures.

To say it with Stefan: Can you fix/enable that?

03 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Schreiber, Gabriel Akira

02 Jul 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Schreiber, Gabriel Akira

29 Jun 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Fan, Daisy

Nice!

How can I get a high resolution eps, e.g., >300dpi? Matlab's documentation says to use the -r option, e.g.,
  print -deps -r300 myfile
but it actually doesn't work. When I look at the produced eps in a software such as Adobe Photoshop the resolution is just 72dpi. Thanks for you input!

03 Jun 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Stefan

Great job!

But still one bug: Exporting does not work if axes is child of uipanel. Seems to be some problem when using cobyobj
Can you fix that?

28 May 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford feng, wei

Great work! You sir saved me a LOT of time.

I've been using your print_eps function for a while and found this today. However, I have a problem with converting images to eps format that has been bugging me. For example, I have two images in a matlab figure. On both images I have used the "plot" function to plot some lines on the images. The plotted lines are gray in color. When I export them into eps format, the lines on the first image would remain gray. But the lines on the second image would change to black. The same thing happens when I have more than two images with plotted lines, in which case all the plotted lines except in the first image will turn black. I was wondering if you can shed some light on this?

Thanks a lot.

28 May 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Guevara Codina, Edgar

Great job!
Finally I can get publication-quality graphs in a simple way.
Thanks Oliver for making it easier than ever before.

06 May 2009 fix_lines Improves the style of lines in MATLAB generated eps files Author: Oliver Woodford gmart

i fixed the dashed line in my eps figure after running this function...

30 Apr 2009 SC - powerful image rendering Useful tool for rendering and outputting information rich images Author: Oliver Woodford wan, Jun

veri nice .bue i didn't try it

29 Apr 2009 real2rgb & colormaps Converts intensity matrices into truecolor images. Author: Oliver Woodford Stanley

25 Apr 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Woodford, Oliver

David Meller: remove the last two input arguments ('start', 'end') from regexp on line 128. Please email me (use the contact author link on my author page) if you get any more errors.

23 Apr 2009 print_pdf Save figures to high quality pdfs with cropped borders and embedded fonts. Author: Oliver Woodford Meller, David

Not compatible with R13 (6.5.0). Gives the following error in the file 'print_pdf.m' on line 128:

??? Error using ==> regexp
Invalid option for regexp: start.

Any ideas?

21 Apr 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Dorion, Christian

Great piece of work, thanks.

A minor thing though... Under my installation, the private/ghostscript.m function had a minor bug that resulted in the whole function being whipped out and replaced by solely the 'gs' path. Just in case it happens to anyone else, here is a simple patch:

--- MY/private/ghostscript.m
+++ ONLINE/private/ghostscript.m
@@ -103,9 +103,8 @@
 fstrm = fread(fh, '*char')';
 fclose(fh);
 % Find the path
-first_sec = regexp(fstrm, '[\n\r]*function path = current_gs_path[\n\r]*path = ''', 'end', 'once');
-second_sec = first_sec + regexp(fstrm(first_sec+1:end), ''';[\n\r]*return', 'once');
-assert(~isempty(first_sec) && ~isempty(second_sec));
+first_sec = regexp(fstrm, '[\n\r]function path = current_gs_path[\n\r]path = ''', 'end', 'once');
+second_sec = first_sec + regexp(fstrm(first_sec+1:end), ''';[\n\r]return', 'once');
 % Save the file with the path replaced
 fh = fopen(fname, 'wt');
 fprintf(fh, '%s%s%s', fstrm(1:first_sec), path, fstrm(second_sec:end));

19 Apr 2009 export_fig Exports figures nicely to a number of vector & bitmap formats. Author: Oliver Woodford Woodford, Oliver

Dan: Currently the only way to change the exported figure size is to change the Matlab figure size before exporting. To get round this, set the paper size options manually within export_fig.

Matt C: Thanks for the great suggestion.

Shameem/Mohammed: I wanted to keep the interface simple, so unfortunately there is no formal way to control file size. Jpeg file size can be changed by varying the quality setting within export_fig. For more options regarding quality/compression, see savefig (also on the FEX).

 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com