フィルターのクリア

rectangle to draw a line

4 ビュー (過去 30 日間)
Vincent I
Vincent I 2013 年 1 月 14 日
Hi, I'm using rectangle to draw a circle then a line in a for loop. However, when I draw the second line, after drawing the circle, the line width is slimmer than the previous drawn line and even the next drawn lines.
I'm confuzed. I saved the handle and looked at the first created line and compared it to the second line. However, they are identical. Any advice?
Thank you
for m=1:10
rectangle('parent',handles.Axes9,'Position',[x,y,30,30],'Curvature',...
[1,1],'FaceColor',color);
rectangle('parent',handles.Axes9,'Position',...
x+14,y+30,1,h],'FaceColor','black');
text(x+8,y+15, {m},'fontsize',14,'color','black',...
'fontweight','bold','parent',handles.Axes9);
end

回答 (2 件)

Image Analyst
Image Analyst 2013 年 1 月 14 日
You probably need to use "hold on" in between those calls. But why not use line() or plot() to create a line? Why use rectangle to create a line?
  5 件のコメント
Jan
Jan 2013 年 1 月 15 日
Do you mean: "that the line is identical except for the handle number"?
Vincent I
Vincent I 2013 年 1 月 15 日
編集済み: Vincent I 2013 年 1 月 15 日
:-) yes. the rectangle "line" is identical except the handle number

サインインしてコメントする。


Jan
Jan 2013 年 1 月 15 日
This has been a useful example.
The code is correct and the display of the graphics is correct also. You see the effect, that rectangle draws to rounded pixel positions. And sometimes they are nearer to each other, such that the line looks smaller. When you resize the figure, you will see, that other lines are concerned.
  5 件のコメント
Malcolm Lidierth
Malcolm Lidierth 2013 年 1 月 16 日
Vincent I
Vincent I 2013 年 1 月 16 日
fixed my issue by doing the following:
rectangle('parent',findobj(0,'Tag','Axes9'),'Position', [x,y,30,30],'Curvature',[1,1],'FaceColor',color);
line([x+15 x+15],[y+30 y+h],'LineWidth',2,'Color','Black','parent',findobj(0,'Tag','Axes9'))
and deleting everything with:
delete(findobj(findobj(0,'tag','Axes9'),'Type','Text','-or','type','rectangle','-or','type','line'))
Thank you for all your help

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by