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!