How can I fill a plot section from a single x,y coordinates?
古いコメントを表示
Hello,
I simply want to fill an unbounded section of a plot from an x,y coordinate. For example, the code below creates a vertical line that divides a plot area into two unbounded regions. I would like to fill in the plot area to the left (indicated by the red circle). Is there a simple way to achieve this? Polygons could be a possible solution, but it may get complicated since the line is not always vertical and the data point could be anywhere.
y=0:100;
x=ones(size(y));
plot(x,y)
hold all
scatter(0.5,50,'r')
axis([0 2 0 100])
Thanks
1 件のコメント
Azzi Abdelmalek
2012 年 8 月 21 日
can we know if a delimùiter is horizontal or vertical?
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2012 年 8 月 21 日
編集済み: Azzi Abdelmalek
2012 年 8 月 21 日
close;
xmin=0;xmax=2;ymin=0;ymax=100
choice=2
y=0:100;
x=ones(size(y));
plot(x,y)
hold all
axis([xmin xmax ymin ymax]);
n=length(y);
if choice==1
x1=[x xmin xmin x(1)];y1=[y ymax ymin y(1)];
fill(x1,y1,'r')
elseif choice==2
x1=[x xmax xmax x(1)] ;y1=[y ymax ymin y(1)];
fill(x1,y1,'r')
end
7 件のコメント
Azzi Abdelmalek
2012 年 8 月 21 日
if there is a curve the program must change
Azzi Abdelmalek
2012 年 8 月 21 日
if choice==1, it fills on the left, if choice==2 it fills on the right. and it may work even it's a curved
Matt Fig
2012 年 8 月 21 日
Is this what you mean by 'fill' in your question? I was picturing more like to make the region all one color.
Azzi Abdelmalek
2012 年 8 月 21 日
you are right, it's better to use fill,
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!