problem with scatter/bubble plot
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
bym
2011-12-28
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 个评论
更多回答(1 个)
the cyclist
2011-12-28
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!