如何控制显示在哪些监视图上? [英] How can I control which monitor plots are displayed on?

查看:85
本文介绍了如何控制显示在哪些监视图上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行MATLAB的3显示器Gentoo Linux系统. MATLAB在中央监视器上运行.我需要MATLAB在左监视器上生成图,但始终在右监视器上生成图.

I have a 3 monitor Gentoo Linux system running MATLAB. MATLAB runs on the center monitor. I need MATLAB to generate plots on the left monitor but it always plots on the right monitor.

我认为这至少部分是由于我的显示器物理配置不规范所致-本质上是2,3,1:

I believe this is at least partially caused by the non-standard way I have my monitors arranged physically - essentially 2,3,1:

>> get(0,'MonitorPositions')

ans =

           1           1        1920        1080
       -3839           1        1920        1080
       -1919           1        1920        1080

有没有一种方法可以在MATLAB中将其作为默认值进行控制?

Is there a way I can control this as a default within MATLAB?

推荐答案

您可以 像这样:

You can set the default figure position on the root object like so:

set(0, 'DefaultFigurePosition', [-3839 1 1920 1080]);

这将创建默认情况下填充左侧监视器的窗口.但是,此默认设置可能会在每次重新启动MATLAB时重置,因此您必须将其放入

This will create windows that fill the left monitor by default. However, this default will likely reset each time you restart MATLAB, so you will have to put it in your startup file if you want it to persist from session to session.

注意:有关以下内容的文档根对象的'MonitorPositions'属性表示:

Note: The documentation for the 'MonitorPositions' property of the root object says this:

每行的前两个元素指示相对于原点的显示位置.每行的最后两个元素指示显示大小.原点是主显示器的左下角.

The first two elements in each row indicate the display location with respect to the origin point. The last two elements in each row indicate the display size. The origin point is the lower-left corner of the primary display.

如果更改将哪个显示器用作主显示器,则左两列中的相对坐标将更改,这意味着您必须更改上面代码行中的位置值.如果您认为显示设置可能经常更改,或者您将在不同的监视器设置上运行代码,则可以通过在左列中查找值最低的监视器位置来确保绘图始终显示在最左侧的监视器上.这是您的操作方法(还可以将以前的默认窗口大小和位置合并到监视器中):

If you change which monitor is used as the primary display, the relative coordinates in the left two columns will change, meaning you will have to change the position value in the above line of code. If you think the display setup may change often, or you will be running code on different monitor setups, then you can ensure plots will always appear on the left-most monitor by looking for the monitor position with the lowest value in the left column. Here's how you could do it (also incorporating the previous default window size and position within a monitor):

monitorPos = get(0, 'MonitorPositions');
figurePos = get(0, 'DefaultFigurePosition');
[~, leftIndex] = min(monitorPos(:, 1));
set(0, 'DefaultFigurePosition', figurePos + [monitorPos(leftIndex, 1:2)-1 0 0]);

这篇关于如何控制显示在哪些监视图上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆