Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab export plot to vector format

All the time previously I was exporting Matlab figures in a raster format (JPG, PNG)

Is there a way to export a plot from Matlab in a vector format (SVG). I need it to inset that plots into LaTeX document.

The only thing, I have found so far is a plugin from mathworks and the answer from stackexchange , but this looks rather too complicated

like image 294
Salvador Dali Avatar asked Dec 09 '12 14:12

Salvador Dali


3 Answers

There is also matlab2tikz and matlabfrag which exports to eps with annotation for importing to LaTeX.

Here is an example of mine where I've used matlabfrag.

I've also discussed this with a Mathworks engineer, who agreed that there is not a nice-and-ready tool for this kind of thing, because everybody wants to do different things with it (I already mention two different LaTeX approaches). So imo the best thing to do is to play around with different tools and see which suits you best.

Most of the times I had to tinker a lot with the axes, font size of labels, etc to get it exactly how I wanted (btw adjusting a legend is the greatest hell).

like image 161
Gunther Struyf Avatar answered Nov 12 '22 16:11

Gunther Struyf


I commonly use both Matlab plots in Latex documents. What I usually use is .eps format, is a vector format that Matlab can export quite good. You should edit the most of it that you can in Matlab, with code or manual in the plot. Then just go File -> export setup and click 'expand axes to fill figure', configure whatever you want and export to .eps, then you can import the image to any vector based software, Inkscape or Adobe Illustrator to do final adjustments if needed. Just bump the eps into Latex, it works perfect. Also pdflatex usually converts EPS to PDF, so you can convert it to PDF before from Inkscape or Illustrator if you want to save time.

like image 33
klausosk Avatar answered Nov 12 '22 16:11

klausosk


For my publications I save the plot as an EPS (which is vectorized), then do any final touches in Inkscape. Then through Inkscape you can export it to something like SVG. Inkscape has a bunch of tools that are handy for cleaning up a plot (such as simplifying paths and shading).

That's how I made the following T-s diagram:

Normal-Shock Solutions on T-s

like image 3
ccook Avatar answered Nov 12 '22 16:11

ccook