Program to open .fig files saved by Matlab
Asked Answered
W

5

19

Is there any program able to open .fig files saved by Matlab?

Williamsen answered 10/8, 2012 at 13:25 Comment(1)
You mean, besides Matlab itself? :-)Abstriction
E
9

Update 29/04/2016

According to johnml1135's answer, fig files are essentially just mat files, and johnml1135 figured out where the various plot elements are stored, for converting a fig file to a Python plot.

Original

According to the answer here the fig file saved by Matlab is in a proprietary binary format. I don't know of any other software capable of loading this format.

Your best option is probably to have the figure saved as a pdf/png from within Matlab depending on the type of figure.

Possible workaround

I recently noticed that octave will load a fig file as a structure, so if you're stuck with trying to open fig files without being able to access Matlab you could try and write an octave function that will load the fig file and reconstitute the plot from the contents of the struct. This would probably require knowing prior information about the plot though.

Euphemie answered 10/8, 2012 at 13:34 Comment(2)
Actually, Python/SciPy can read the files as seen here.Andi
@Andi : Thanks for the link to your solution - it seems then that fig files are just mat files and you've figured out the structures that the various plot items correspond to - nice!Euphemie
S
4

As mentioned by @mutzmatron, .fig is not easily opened, but this is mostly due to it being poorly documented (not sure about proprietary aspects...). As can be seen here, there is a simple format to them quite similar to .mat files, which might give you another direction to go in.

I've always been quite fond of plot2svg. It exports Matlab figures (most anyway) to the non-proprietary vector format SVG.

Sandalwood answered 10/8, 2012 at 13:44 Comment(2)
I tried plot2svg once and found it a bit buggy - but I was mostly wondering what the pros and cons are to svg over pdf?Euphemie
Yes, it's buggy, and Mathworks should start supporting it natively! Pros and cons are too numerous -- it deserves its own post. Most relevant for me has always been that SVG is supported by most browsers natively, whereas PDF support has always been difficult. Also, image conversion from PDF to something else can be a pain, whereas SVG has never treated me badly.Sandalwood
M
2

Create a script (for example FigViewer.m) containing simply the command figure and compile it by running

mcc -e -v FigViewer.m

from the Matlab command window. This way you get a platform-dependent application that runs on any computer with the right version of the Matlab Compiler Runtime installed, which is freely available. If you are looking for further information on the Matlab Compiler, use the MathWorks homepage instead of Google since some information is available only behind a login screen and thus cannot be found by Google.

Mcconnell answered 29/7, 2014 at 16:32 Comment(0)
A
2

Python through SciPy has the ability to open a fig file (scipy.io.loadmat), which is really just a mat file by another name. This post can show simple line plots with labels, etc. but can easily be extended. It is fairly straightforward to grab the data from it as well.

Andi answered 28/4, 2016 at 18:43 Comment(0)
D
-2

As it turns out, there is actually a command in matlab itself that lets you save any figures you want to file in whatever format. Try this:

print('theNameYouWant','-dpng')

This lets you save the figure to a png file which can then be opened by numerous applications like MS Paint or Paintbrush on Mac

Degas answered 12/7, 2016 at 2:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.