problem with scatter/bubble plot
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi,
i have created a vector containing coordinates of a circle in a matrix.
i want to display these locations as dots in a plot.further i want to color these dots in a clockwise increasing color scheme. i have written a code but experienced a problem : the color vector which i created does not seem to be mapped linearly to my location points
code:
matrix = ones(512,512);
mittelpunkt_x = 256;
mittelpunkt_y = 256;
radius = 33;
for i=1:size(matrix,1)
for j = 1:size(matrix,2)
matrix(i,j) = norm([i j]-[mittelpunkt_x,mittelpunkt_y],2);
if matrix(i,j)<=radius
matrix(i,j)=0;%10;
elseif matrix(i,j)<radius+1 && matrix(i,j)>radius
matrix(i,j)=1;
else
matrix(i,j)=0;
end
end
end
b=0.00490196078
[r,c]=find(matrix==1);
color=[b:b:1];
y=[r c];
scatter(r,c,50,color,'filled')
i hope someone can help me with this
g3rm9
0 comentarios
Respuesta aceptada
bym
el 28 de Dic. de 2011
something like this?
t = 0:pi/6:2*pi
t(13)=[];
x = cos(t);
y = sin(t);
c = spring(12);
scatter(x,y,[],c,'filled')
4 comentarios
Más respuestas (1)
the cyclist
el 28 de Dic. de 2011
I'm not sure I understand what the problem is. When I run your code, I see a circle with varying color going around it, which I assume is what you want. It may not look like a circle, because the displayed axes do not have equal aspect ratio. You may want to put the following code after your scatter() command:
>> axis equal
>> axis square
If that is not what you mean, then you will need to be more explicit by what "mapped linearly to my location points" means.
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!