Is it possible to get color inside boxes?

2 visualizaciones (últimos 30 días)
prabhu singh
prabhu singh el 28 de Jul. de 2022
Respondida: Image Analyst el 28 de Jul. de 2022
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

Respuestas (1)

Image Analyst
Image Analyst el 28 de Jul. de 2022
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;

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by