2D Graphythgxgnk
2D Graphythgxgnk
Statements
Statements are frequently of the form: variable = express
Example :
x = 0:pi/40:4*pi;
plot(x, sin(x))
Line styles, markers and color
Line styles, markers and colors may be selected for a
graph with a string argument to plot, e.g. plot(x, y, ’--’)
joins the plotted points with dashed lines.
Plot(x, y, ‘line specifiers’ , ‘PropertyName’, PropertyValue)
vectors
Optional: Type and color Optional properties : line
of the line markes width Marker’s size and edge,
fill colors
Example :
if coordinates (0, 1) & (4, 3)
plot(x, y) : If one of x or y is a
matrix and the other is a vector,
the rows or columns of the matrix
are plotted against the vector,
using a different color.
EXAMPLE : x= 0:0.1:1
y =[x.^2;
x.^3; x.^4]
y=y'
plot(x,y)
MULTIPLE PLOTS ON THE DIFFERENT plotyy()
AXIS :
x=1:0.1:3
y=x.^2
z =10000*x.^1.2;
plotyy(x,y,x,z)
PLOTS WITH LOGARITHMIC AXIS
• semilogy(x,y) : Plot y vs x with a log scale
for the y axis and linear scale for the x axis
• semilogx(x,y) : Plot y vs x with a log scale
for the x axis and linear scale for the y axis
• loglog(x,y) : Plot y vs x with a log scale for
both axes
EXAMPLE : x=linspace(0.1, 60, 1000)
y=2.^(-0.2*x+10);
semilogx(x,y)
OR
loglog(x,y)
PLOTS WITH SPECIAL GRAPHICS
Function Graphics
hist(x,y) Histogram
Tittle, Label’s, Grid, text
•If x and y are vectors, the text is written at each point. If the
text is an indexed list, successive points are labeled with
corresponding rows of the text.