I have following data set.
x y
0.01 1.88
0.05 1.92
0.10 1.60
0.15 1.23
0.20 1.00
0.25 1.00
0.95 1.00
0.99 1.00
I want to create a plot like this:
Untitled.png
I also want to add marker points as well to the graph. thank you.

 Akzeptierte Antwort

KSSV
KSSV am 6 Jun. 2019

1 Stimme

A = [0.01 1.88
0.05 1.92
0.10 1.60
0.15 1.23
0.20 1.00
0.25 1.00
0.95 1.00
0.99 1.00 ] ;
x = A(:,1) ; y = A(:,2) ;
x1 = [x(1:5); x(1)] ;
y1 = [y(1:5); 1] ;
x2 = [x ; 1 ; min(x) ; x(1) ] ;
y2 = [y ; 2 ; 2 ;y(1)] ;
patch(x1,y1,'r')
hold on
patch(x2,y2,'b')

4 Kommentare

Milan Kumar
Milan Kumar am 6 Jun. 2019
Bearbeitet: Milan Kumar am 6 Jun. 2019
Add square marker for the points?
KSSV
KSSV am 6 Jun. 2019
A = [0.01 1.88
0.05 1.92
0.10 1.60
0.15 1.23
0.20 1.00
0.25 1.00
0.95 1.00
0.99 1.00 ] ;
x = A(:,1) ; y = A(:,2) ;
x1 = [x(1:5); x(1)] ;
y1 = [y(1:5); 1] ;
xi = linspace(min(x),max(x)) ;
yi = linspace(min(y),max(y)) ;
[X,Y] = meshgrid(xi,yi) ;
idx = inpolygon(X,Y,x1,y1) ;
figure
hold on
plot(X(idx),Y(idx),'+r')
plot(X(~idx),Y(~idx),'xb')
Milan Kumar
Milan Kumar am 6 Jun. 2019
Thank you for all the help. One last thing if for the follwoing data set:
A = [0.01 1.88
0.05 1.92
0.082 1.88
0.10 1.60
0.15 1.23
0.20 1.00
0.25 1.00
0.95 1.00
0.99 1.00 ]
The graph I want is:
Untitled.png
Please help in understanding the logic of creating area.
KSSV
KSSV am 6 Jun. 2019
Logic is simple......you need to define the polygons...provide the polygon vertices.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 6 Jun. 2019

Kommentiert:

am 6 Jun. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by