How to put a color in a this graph? (code)
Show older comments
The code is:
R=3;
R2=2;
for i=1:2
for j=1:6
t=linspace((i-1)*60*pi/180,i*60*pi/180);
t2=linspace(i*60*pi/180,(i-1)*60*pi/180);
x=(R-(j-1))*cos(t):
y=(R-(j-1))*sin(t);
x2=(R2-(j-1))*cos(t2);
y2=(R2-(j-1))*sin(t2);
X=[x2.x.x2(1)];
Y=[y2,y,y2(1)];
figure
patch(X,Y,'r')
axis equal
end
end
I tried to use "imagesc(X,Y,c)" where c is a vector with some values.
I want to know how to colorate the graph where the color has to be related to each value of "c".
2 Comments
madhan ravi
on 14 Nov 2018
provide c datas
Carlos Nicolas Gordillo Olivera
on 14 Nov 2018
Answers (1)
madhan ravi
on 14 Nov 2018
C=[500 600 750.6 800 400.7 350 500.4 487.3 125.6 258.6 158.3 147.6]
R=3;
R2=2;
for i=1:2
for j=1:6
t=linspace((i-1)*60*pi/180,i*60*pi/180);
t2=linspace(i*60*pi/180,(i-1)*60*pi/180);
x=(R-(j-1))*cos(t);
y=(R-(j-1))*sin(t);
x2=(R2-(j-1))*cos(t2);
y2=(R2-(j-1))*sin(t2);
X=[x2,x,x2(1)];
Y=[y2,y,y2(1)];
figure
patch(X,Y,'r')
axis equal
end
end
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!