How to plot 4 different backgrounds in a figure?

조회 수: 1 (최근 30일)
Diego Alberto León López
Diego Alberto León López 2020년 10월 21일
댓글: Diego Alberto León López 2020년 11월 21일
Hello, im trying to change the background of a figure, i need to have it divided in four sections and then add them a background color, just as i show in the picture.
Hope someone can help me. Thanks.

채택된 답변

Akira Agata
Akira Agata 2020년 10월 30일
How about using uipanel?
The following is an example:
% Sample colormap
cMap = rand(4,3);
% Graphic object array
hPanel = gobjects(4,1);
hAxes = gobjects(4,1);
hPlot = gobjects(4,1);
% Relative position of each panel
[x,y] = meshgrid([0 0.5]);
x = x(:);
y = y(:);
% Create the desired plot
hFig = figure;
for kk = 1:4
hPanel(kk) = uipanel(...
'Parent', hFig,...
'Units', 'normalized',...
'Position', [x(kk) y(kk) 0.5 0.5],...
'BackgroundColor',cMap(kk,:));
hAxes(kk) = axes(...
'Parent', hPanel(kk));
plot(hAxes(kk),magic(4));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by