4.8

4.8 | 5 ratings Rate this file 25 Downloads (last 30 days) File Size: 15.01 KB File ID: #11632
image thumbnail

figure to latex

by David Krause

 

04 Jul 2006 (Updated 02 Oct 2007)

Converts a displayed figure to latex .tex format. The code can handle zoomed in plots

| Watch this File

File Information
Description

Create your 2D, multiple axes plot, and then convert it to a LaTeX .tex file. Then, include the .tex file in your thesis or paper using pstricks. The code uses the data contained in the figure window, so as long as you can create your 2D plot, it should be converted to a .tex file (I haven't tried it with stem plots, semilog, etc).

Also, if you have adjusted the axis so that parts of the lines are outside of the plot area, the code should be able to handle that.

You can use standard LaTeX commands (i.e., $\pi$, \acs{WDM}) in your titles and annotations. The code automatically adds the \\ for use with fprintf.

The arguments include being able to adjust the weight (thickness) of the ticks and lines, and a comment line (useful for tracing where the data came from if your figures are ending up in a common directory). Also, you can set the size of the plot rectangle.

If you want to make some small adjustments, the output .tex file can be opened in jPicEdt.

Then, create the .dvi file, convert the .dvi to .ps (run dvips), and then create your pdf (run ps2pdf).

Oddly, my version of MATLAB does a poor job of placing the x10^9 type of annotations (see the screen shot). So, I corrected for this in the LaTeX output.

Please let me know what you think!

Cheers, David.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
fig2tex
This submission has inspired the following:
surf to LaTeX, fig2tex - With Marker

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
13 Jul 2006 CK Ho

Nice, works well and the graph looks great in PS format. However, it would be great if text/grid lines can be drawn in Latex too.

21 Jul 2006 Jamie Gaudette

This program works excellent. It saved my life. I'll bet the author is really handsome.

25 Aug 2006 Michael Amrhein

Very useful for us! Thanks a lot. Runs fine under Windows/MiKTeX and Mac/TeXShop. Errors under Linux.

03 Feb 2007 Feng Gan

Extremely useful!

28 Sep 2007 jon erickson

Looks potentially very useful. the matlab function works just fine. however, when I run try to "compile" the latex file example, it barfs.
 
error is almost certainly on the latex side. i'm using miktex 2.7 on windows with texniccenter. appears i have all packages except latexsym.

any ideas what is going wrong?

i'm an experienced latex user and placing figures with \includegraphics works fine, but for the life of me can't figure out what is going wrong with the example, and using \input instead.

I have all packages except latexsym

23 Sep 2008 Florian Xaver

Hi, I got this error:

./the_figure.tex:4671:TeX capacity exceeded, sorry [save size=5000]. ...,linecolor=userLineColor]{-}(47.70,32.1)

I am using Linux...
http://www.mackichan.com/index.html?techtalk/594.htm~mainFrame

17 Feb 2012 Essam Soliman

what about the legend, could you please tell me how to show the legend in tex file

Please login to add a comment or rating.
Updates
02 Oct 2007

Slight bug caused some LaTeX plots not to be created correctly.

Tag Activity for this File
Tag Applied By Date/Time
graphics import David Krause 22 Oct 2008 08:32:04
graphics export David Krause 22 Oct 2008 08:32:04
figure plot latex pstricks multiple axes David Krause 22 Oct 2008 08:32:04
figure plot latex pstricks multiple axes Essam Soliman 17 Feb 2012 05:15:43

Contact us at files@mathworks.com