DPI-Aware Behavior in MATLAB - MATLAB & Simulink (original) (raw)

Starting in R2015b, MATLAB® is DPI-aware, which means that it takes advantage of your full system resolution to draw graphical elements (fonts, UIs, and graphics). Graphical elements appear sharp and consistent in size on these high-DPI systems:

DPI-aware behavior does not apply to Linux® systems.

Previously, MATLAB allowed some operating systems to scale graphical elements. That scaling helped to maintain consistent appearance and functionality, but it also introduced undesirable effects. Graphical elements often looked blurry, and the size of those elements was sometimes inconsistent.

Visual Appearance

Here are the visual effects you might notice on high-DPI systems:

Using Object Properties

These changes to object properties minimize the impact on your existing code and allow MATLAB to use the full display resolution when rendering graphical elements. All UIs you create in MATLAB are automatically DPI-aware applications.

Units Property

When you set the Units property of a graphics or UI object to 'pixels', the size of each pixel is now device-independent on Windows and Macintosh systems:

Your existing graphics and UI code will continue to function properly with the new pixel size. Keep in mind that specifying (or querying) the size and location of an object in pixels might not correspond to the actual pixels on your screen.

For example, each screen pixel on a 192-DPI Windows system is 1/192nd of an inch. In this case, twice as many screen pixels cover the same linear distance as the device-independent pixels do. If you create a figure, and specify its size to be 500-by-400 pixels, MATLAB reports the size to be 500-by-400 in the Position property. However, the display uses 1000-by-800 screen pixels to cover the same graphical region.

Note

Starting in R2015b, MATLAB might report the size and location of objects as fractional values (in pixel units) more frequently than in previous releases. For example, your code might report fractional values in the Position property of a figure, whereas previous releases reported whole numbers for that same figure.

Root ScreenSize Property

The ScreenSize property of the root object might not match the display size reported by high-DPI Windows systems. Specifically, the values do not match when the Units property of the root object is set to 'pixels'. MATLAB reports the value of the ScreenSize property based on device-independent pixels, not the size of the actual pixels on the screen.

Root ScreenPixelsPerInch Property

The ScreenPixelsPerInch property became a read-only property in R2015b. If you want to change the size of text and other elements on the screen, adjust your operating system settings.

Also, you cannot set or query the default value of the ScreenPixelsPerInch property. These commands now return an error:

get(groot,'DefaultRootScreenPixelsPerInch') set(groot,'DefaultRootScreenPixelsPerInch')

The factory value cannot be queried either. This command returns an error as well:

get(groot,'FactoryRootScreenPixelsPerInch')

Using print, getframe, and publish Functions

getframe and print Functions

When using the getframe function (or the print function with the -r0 option) on a high-DPI system, the size of the image data array that MATLAB returns is larger than in previous releases. Additionally, the number of elements in the array might not match the figure size in pixel units. MATLAB reports the figure size based on device-independent pixels. However, the size of the array is based on the display DPI.

publish Function

When publishing documents on a high-DPI system, the images saved to disk are larger than in previous releases or on other systems.

See Also

Root Properties | Figure Properties