Is it possible to get color inside boxes?

2 次查看(过去 30 天)
x1=0;
x2=1;
y1=0;
y2=1;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
plot(x, y, 'b-', 'LineWidth', 3);
hold on;
x1=0.25;
x2=.75;
y1=0.25;
y2=.75;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
plot(x, y, 'b-');
xlim([-1, 2]);
ylim([-1, 2]);
Inner box i want to fill color with yellow
and outer box fill blue color but axes should not be there
2018a version

回答(1 个)

Image Analyst
Image Analyst 2022-7-28
Try this:
% The inner box I want to fill with yellow color
% and outer box fill with blue color, but the axes should not be there.
x1=0;
x2=1;
y1=0;
y2=1;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
r1 = [x1, y1, x2-x1, y2-y1]
r1 = 1×4
0 0 1 1
x1=0.25;
x2=.75;
y1=0.25;
y2=.75;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
r2 = [x1, y1, x2-x1, y2-y1]
r2 = 1×4
0.2500 0.2500 0.5000 0.5000
% Plot them
rectangle('Position', r1, 'FaceColor', 'b')
hold on;
rectangle('Position', r2, 'FaceColor', 'y')
hold on
xlim([-1, 2]);
ylim([-1, 2]);
% Turn off the axes and tick marks
axis off;

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by