How do I run Matlab from Python, but save figures to a file?
19 views (last 30 days)
I am successfully running Matlab from Python. The Matlab code I have displays 2 figures. Upon running Python, would rather those figures go to a file. Is there a switch, or some such option to get that to happen? Rather not rewrite Matlab code with some sort of Python specific switch.
Bo Li on 19 Oct 2015
There is no such flag. Python Engine allows you to have full control over MATLAB from Python. You can simply save a figure like following example shows:
>>>eng.plot(matlab.double([1,2,3,4])) %create a plot
>>>eng.savefig("foo.fig",nargout=0) %save current figure to "foo.fig"
>>>eng.close() %close current figure