.fig - это файлы .mat (содержащие структуру), см.
http://undocumentedmatlab.com/blog/fig-files-format/
В качестве ссылки, которую вы указываете состояния, структуры поддерживаются только до версии 7.1:
http://www.scipy.org/Cookbook/Reading_mat_files
Итак, в MATLAB я сохраняю, используя -v7:
plot([1 2],[3 4])
hgsave(gcf,'c','-v7');
Затем в Python 2.6.4 я использую:
>>> from scipy.io import loadmat
>>> x = loadmat('c.fig')
>>> x
{'hgS_070000': array([[<scipy.io.matlab.mio5.mat_struct object at 0x1500e70>]], dtype=object), '__version__': '1.0', '__header__': 'MATLAB 5.0 MAT-file, Platform: MACI64, Created on: Fri Nov 18 12:02:31 2011', '__globals__': []}
>>> x['hgS_070000'][0,0].__dict__
{'handle': array([[1]], dtype=uint8), 'children': array([[<scipy.io.matlab.mio5.mat_struct object at 0x1516030>]], dtype=object), '_fieldnames': ['type', 'handle', 'properties', 'children', 'special'], 'type': array([u'figure'], dtype='<U6'), 'properties': array([[<scipy.io.matlab.mio5.mat_struct object at 0x1500fb0>]], dtype=object), 'special': array([], shape=(1, 0), dtype=float64)}
Где я использовал .__dict__
, чтобы увидеть, как пройти через структуру. Например. чтобы получить XData
и YData
я могу использовать:
>>> x['hgS_070000'][0,0].children[0,0].children[0,0].properties[0,0].XData
array([[1, 2]], dtype=uint8)
>>> x['hgS_070000'][0,0].children[0,0].children[0,0].properties[0,0].YData
array([[3, 4]], dtype=uint8)
Показывает, что я использовал plot([1 2],[3 4])
в MATLAB (ребенок - это ось, а внук - серия строк).