arokem / python-matlab-bridge

A simple Python => MATLAB(R) interface and a matlab_magic for ipython
BSD 2-Clause "Simplified" License
335 stars 96 forks source link

Cannot use plot() on MacOS & Matlab R2016b #246

Open tsdev opened 7 years ago

tsdev commented 7 years ago

I am using python 3.6.0 and the latest version of pymatbrige with Matlab R2016b on MacOS 10.12.3. I can communicate with Matlab fine and execute commands, but when I call a plotting script I get the following output: {'content': {'stdout': 'Unable to create output using specified size and resolution. Specify a smaller value for the PaperPosition property of the figure or specify a smaller resolution value.', 'datadir': '/private/tmp/MatlabData/'}, 'result': [], 'stack': [{'file': '/Applications/MATLAB_R2016b.app/toolbox/matlab/graphics/print.m', 'name': 'print', 'line': 102}, {'file': '/Applications/MATLAB_R2016b.app/toolbox/matlab/general/saveas.m', 'name': 'saveas', 'line': 168}, {'file': '/usr/local/lib/python3.6/site-packages/pymatbridge-0.6.dev0-py3.6.egg/pymatbridge/matlab/util/make_figs.m', 'name': 'make_figs', 'line': 14}], 'success': False}

Matlab is running with -nodesktop option. I tried to run it with the desktop by using: from pymatbridge import Matlab mlab = Matlab(startup_options=' -nosplash') still the Matlab desktop didn't appear.

arokem commented 7 years ago

I have seen similar things and have not been able to debug this. I think this has to do with changes introduced in MatlabR2016a, but I am not sure how to get around this.

tsdev commented 7 years ago

I could fix it, if I run Matlab with the -desktop option. However I found that plotting seems to be seriously lagging possibly due to the ZMQ code that keeps Matlab busy. I would like to produce standard Matlab plot figures that the user can interact with. However, even after issuing the drawnow command, it takes forever until the plot draws. And it has a very long reaction time to user interaction (rotating the figure with the mouse, etc.).

Is this normal behaviour, since I have no experience with the ZMQ library? Is there a way to change the polling interval of ZMQ to give Matlab more time to refresh the figure?

SirBenedick commented 4 years ago

Had the same issue, on Ubuntu 18.04 with Matlab R2019b.

Running matlab.run_code("set(0, 'defaultfigureunits', 'pixels')") before the figure generating code fixed this problem for me.