matlab - 如何在Matlab中绘制图形背景?

标签 matlab plot annotations matlab-figure subplot

我有一组 6×3 的子图,其中两个子图总是相关的。我想更改其中两个图背后的背景颜色(而不是图本身的背景)以在光学上“连接”它们。

我用矩形注释尝试过,但无法将其隐藏在绘图后面。 uistack 也没有用。使用 'bottom' 选项,矩形仍然在图的前面。

有什么办法可以在情节背后绘制背景吗?

最佳答案

这里有一个小例子,说明如何使用 axes 执行此操作创建一个带有彩色背景的轴和 uistack将它移到后面:

figure
h1 = subplot(2,2,1);
h2 = subplot(2,2,2);
h3 = subplot(2,2,3);
h4 = subplot(2,2,4);

p1 = get(h1,'Position');
p2 = get(h2,'Position');
border = 0.3*p1(1);
x1 = p1(1)-border;
y1 = p1(2)-border;
width1 = p2(3)+p2(1)-p1(1)+2*border;     
height1 = max(p1(4),p2(4))+2*border;
ax1 = axes('Position', [x y width1 height1],...
           'Color','r','XTick',[],'XColor','r','YTick',[],'YColor','r');
uistack(ax1,'bottom')

p3 = get(h3,'Position');
p4 = get(h4,'Position');
border = 0.3*p3(1);
x2 = p3(1)-border;
y2 = p3(2)-border;
width2 = p4(3)+p4(1)-p3(1)+2*border;
height2 = max(p3(4),p4(4))+2*border;
ax2 = axes('Position', [x2 y2 width2 height2],...
           'Color','b','XTick',[],'XColor','b','YTick',[],'YColor','b');
uistack(ax2,'bottom')

这会产生一个看起来像这样的图形: figure window

关于matlab - 如何在Matlab中绘制图形背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19849426/

相关文章:

python - plotly.figure_factory.create_scatterplot 停止工作?

php - 从 $_POST 请求(不是从 URL)使用 ParamConverter

matlab - 如何在 MATLAB 中创建自定义 "Probability Distribution Object"

matlab - 错误: element number 2 undefined in return list

arrays - 在 MATLAB 中将函数分布在数组的单个维度上?

matlab - matlab 是否有嵌套多项式评估函数(horners 算法)

python - 绘制二维矩阵中特征的存在情况

r - 针对特定条件在 R 中格式化 X Axis 标签

java - 使用 @Test(dependsOnMethods=..) testNG 注解标记测试方法,使它们不执行

java - 如何对 Spring MVC 注释 Controller 进行单元测试?