Azzera filtri
Azzera filtri

Is it possible to get color inside boxes?

3 visualizzazioni (ultimi 30 giorni)
prabhu singh
prabhu singh il 28 Lug 2022
Risposto: Image Analyst il 28 Lug 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

Risposte (1)

Image Analyst
Image Analyst il 28 Lug 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;

Categorie

Scopri di più su Graphics Object Properties in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by