Drawing Polygons and Points

11 ビュー (過去 30 日間)
Hugo
Hugo 2011 年 2 月 7 日
Hi,
Today i was trying to draw a polygon and some points on the same figure. I drawed the polygon using the "fill" command and it worked just fine. But then i tried to plot the other points using the "plot" function ( plot(x, y, '*') ) and the image with the points took the place of the polygon. Is there a way for me to plot the polygon AND the points so i can compare them? Oh, and the polygon doesn't really have to be filled, the perimeter lines are enough.
Thank you (:

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 2 月 7 日
doc hold
To understand. The solution:
figure;
fill(your_stuff)
hold on
plot(your_stuff)

その他の回答 (2 件)

Patrick Kalita
Patrick Kalita 2011 年 2 月 7 日
While hold works, you might consider using low-level graphics functions like patch and line for this task. These functions do not reset the axes like fill or plot.
Here's an example:
patch(cos(0:pi/4:2*pi), sin(0:pi/4:2*pi), 'r')
line(-0.5:0.1:0.5, -0.5:0.1:0.5, 'Marker', '*', 'LineStyle', 'none')

Hugo
Hugo 2011 年 2 月 7 日
Hey, Sean's answer worked!!
Thank you very much.
I will try your suggestion now Patrick, thanks everyone :D

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by