【问题标题】:change background color of subplot area更改子图区域的背景颜色
【发布时间】:2016-02-18 12:36:10
【问题描述】:

我打开了一个带有 2 个子图 ([1,2]) 的图。在第一个子图中,我绘制了一个大小小于子图的点云对象,如下所示(忽略子图 2 中的图): 请注意,图的背景已填满了子图 1 未使用的空间。

我正在寻找一种方法来控制子图未使用的空间背景颜色。例如,对于红色背景:

有什么想法吗?

【问题讨论】:

  • 绘制完你的情节后添加set(H,'Color',[1 0 0]);怎么样?这里H 是第一个子图的句柄
  • 嗨,谢谢,但是当我这样做时,我发现只有点云对象 1 中的白色区域变成了红色,而不是我想要的所有背景颜色
  • 哦,我对此感到抱歉

标签: matlab figure subplot


【解决方案1】:

你不能轻易地做你想做的事。可能最简单的做法是将您的情节放在uipanel 中并以这种方式设置

f = figure()
panel1 = uipanel('Parent', f, ...
                 'Units', 'norm', ...
                 'Position', [0 0 0.5 1], ...
                 'BorderType', 'none');

panel2 = uipanel('Parent', f, ...
                 'Units', 'norm', ...
                 'Position', [0.5 0 0.5 1], ...
                 'BorderType', 'none');

ax1 = axes('Parent', panel1);
ax2 = axes('Parent', panel2);

set(panel1, 'BackgroundColor', 'r')
set(panel2, 'BackgroundColor', 'g')

【讨论】:

  • 嗨,按照你说的做之后,我得到了这个错误: 你知道如何解决吗? (对不起,帖子看起来如何,我不知道如何修复它)
  • 你传递给showPointCloudh是什么?
  • 嗨。非常感谢您的帮助!自上一篇文章以来,我的代码已经更改,现在我无法理解我是如何得到这个错误的。但是,当我扭动时:'ptCloudScene = pcread('teapot.ply'); hAxes = showPointCloud(ptCloudScene,'VerticalAxis','Z','VerticalAxisDir','Down'); cameratoolbar('SetCoordSys','z') panel1 = uipanel('Parent',f); set(hAxes,'parent',panel1)' 我得到了 uipanel 内部的点云,但它很小并且不在中心
  • 也许把set(hAxes, 'Parent', panel1)改成set(hAxes, 'Parent', panel1, 'Units', 'normalized', 'position', [0.05 0.05 0.9 0.9])
  • 嗨,它没有解决问题 8-( 我将使用我的代码发布关于 is 的前问题
猜你喜欢
  • 1970-01-01
  • 2018-06-11
  • 2016-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-22
  • 2022-01-25
  • 2011-03-12
相关资源
最近更新 更多