How to get different colours for different regions for this problem

6 visualizaciones (últimos 30 días)
How to get different colours for different regions for this problem? Here are 10 regions and I want to colour the regions? How to modify the code to get the desired result?
x=0:.00001:1;
y=x.*x;
plot(x,y,'r')
hold on
z=sqrt(x);
plot(x,z);
hold on
y=x;
plot(x,y,'g')
y=1-x;
hold on
plot(x,y,'k')
x=0:.00001:.334;
y=1-2*x;
hold on
plot(x,y,'r')
axis([0 1 0 1])
Untitledss.jpg
  2 comentarios
KSSV
KSSV el 17 de Jun. de 2019
Take the vertices of required closed area and use patch or fill.
Atom
Atom el 17 de Jun. de 2019
How to do that? Please show me by one example using the code above

Iniciar sesión para comentar.

Respuesta aceptada

Robert U
Robert U el 17 de Jun. de 2019
Editada: Robert U el 18 de Jun. de 2019
Hi pallav pal,
one example patch as requested. All others can be drawn accordingly.
x1=0:.00001:1;
x2=0:.00001:.334;
y1=x1.*x1;
z1=sqrt(x1);
y2=x1;
y3=1-x1;
y4=1-2*x2;
plot(x1,y1,'r')
hold on
plot(x1,z1);
plot(x1,y2,'g')
plot(x1,y3,'k')
plot(x2,y4,'r')
axis([0 1 0 1])
area1 = min(y1,y3);
patch('XData',[x1,0],'YData',[area1,0],'FaceAlpha',0.7,'FaceColor','red')
Kind regards,
Robert
  5 comentarios
Robert U
Robert U el 26 de Jun. de 2019
Editada: Image Analyst el 30 de Jun. de 2019
x1=0:.00001:1;
x2=0:.00001:.334;
y1=x1.*x1;
z1=sqrt(x1);
y2=x1;
y3=1-x1;
y4=1-2*x2;
plot(x1,y1,'r')
hold on
plot(x1,z1);
plot(x1,y2,'g')
plot(x1,y3,'k')
plot(x2,y4,'r')
axis([0 1 0 1])
area1 = min(y1,y3);
% resample y4, out of range set to Zero
y4res = interp1(x2,y4,x1,'linear',0);
% define boolean selections
boolSel1 = z1>=y4res & z1<=y3;
boolSel2 = y3 >= y2 & z1 >= y3;
boolSel3 = y2 >= y4res;
boolSel4 = y4res >= y2 & y4res <= z1;
%create patch y coordinates of "smallest area"
area2 = [z1( boolSel1 ) y3(boolSel2) flip(y2(boolSel3)) flip(y4res(boolSel4))];
patch('XData',[x1,0],'YData',[area1,0],'FaceAlpha',0.7,'FaceColor','red')
patch('XData',[x1(boolSel1|boolSel2),flip(x1(boolSel3|boolSel4))],'YData',[area2],...
'FaceAlpha',0.7,'FaceColor','green')
0000 Screenshot.png
Kind regards,
Robert

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by