5

I have a problem of compatibility between Linux and MacOS with a Matlab Gui. The graphical interface is developped under Linux Debian 7.0. Here's the aspect on this platform :

enter image description here

Now, I execute the .m file on MacOS and here's the result :

enter image description here

As you can see, the panel (the box where there are the 3 disks on the first figure (sorry, the 3 disks doesn't appear on the second)) and, more globally, the figure on MacOS 10.9.5 is stretched horizontally, i.e the window is wider than high.

I tried to change Units (tried with characters, normalized, pixels) but nothing does it.

it does not bother me to have a different font for "edit" boxes and buttons but I would like to have the same size ratio under both OS for the panel, i.e to have a square panel like under Linux Matlab.

If someone could help me, this would be nice

Thanks

  • 6
    You would get more help if you posted a minimal example that reproduce the problem – Luis Mendo Jun 19 '15 at 21:59
  • Mac displays can use some funky (_unconventional_) resolutions and to accommodate that they also use some unconventional DPI settings. The first thing I would do is to check that the DPI settings are comparable on both your OSs. For DPI settings in MAC, you can look [here](http://superuser.com/questions/13412/change-dpi-on-osx) or [here](http://www.eizoglobal.com/support/compatibility/dpi_scaling_settings_mac_os_x/index.html). For linux, you can start [here](http://askubuntu.com/questions/197828/how-to-find-and-change-the-screen-dpi) – Hoki Jun 25 '15 at 09:59

1 Answers1

1

The trick is not only to set the 'Units' to 'pixels' to your gfx objects, but also use those units to set the position. :-)

In the following code snippet ha is the handle of the axes, and hf the handle of the enclosing figure. You can force a certain size in pixels for the axes:

set(hf, 'Units', 'pixels'); %// Not necessary, but better not mix units

set(ha, 'Units', 'pixels');
pos = get(ha, 'position');
set(ha, [pos(1:2), 400, 400]); %// 400x400 pixels

You can apply this to the position of any of the graphical objects in the figure.

  • I've created a MATLAB chat room for us to discuss things MATLAB related, or for discussions that span beyond the limitations of a single comment. Visit us when you have time! - http://chat.stackoverflow.com/rooms/81987/matlab – rayryeng Jun 30 '15 at 18:04