Professional Documents
Culture Documents
licensing details
DAY 5
BASIC 2D PLOTS
MODIFYING PLOT APPEARANCE
MULTIPLE PLOTS
ADJUSTING AXES
SPECIAL 2D PLOTS
3D PLOTS
ECE105 – Cody Anderson
Basic plotting functions
ezplot()
fplot()
plot()
ezplot and fplot
xlabel('\bf Radius [cm]', 'FontSize', 18, 'FontName', 'Arial', 'EdgeColor', [1 0.2 0])
“y vs. x”
The phrasing used when describing a
plot tells us which is the dependent
and independent variable:
Dependent Independent
variable (y) variable (x)
comes first comes last
3. Apply xlim
1. Original plot
Some syntaxes for axis
axis( [xmin, xmax, ymin, ymax] )
Set the limits for both x- and y-axes in one command
axis equal
Set the axis limits equal for x and y
axis square
Make the axis box square
axis off
Toggle off the axis labeling and tick marks
Example of axis vector
Example of axis off
The need for log-scale axes
Most often, we use linear axes
Add a consistent amount
between tick marks
Sometimes, a logarithmic axis
is useful
Multiply a consistent amount
(usually 10 or e) between
tick marks
Huge values in later data
make it impossible to view
When use logarithmic? differences in early data
Modeling an exponential
relationship
Data extends across multiple
orders of magnitude
log-scale axes
With the log-scale y-axis: Each tick mark is 100 times the previous tick mark
We can see the differences in the early data
Axis scale functions
plot(x,y) – x- and y-axes are both linear
Indicates that 15
evenly spaced bins
will be used
Plot of Z = X + Y
X=3
X=2 Y=2
Y=8 Z=5
Z = 10
meshgrid
meshgrid creates all combinations of x and y
Returns square grid coordinates of size length(x) by length(y)
[x, y] = meshgrid(-4:0.2:4);
z = exp(-0.5*(x.^2+y.^2));
contour(x, y, z)
colorbar
Surface plot
surf(x,y,z)
Mesh plot
mesh(x,y,z)
Except where otherwise noted, this work is licensed under the Creative
Commons Attribution-NonCommercial 4.0 International License.