Matlab Basic Plotting Commands
DISCLAIMER: there have been many changes over the years to plotting commands, especially starting with MATLAB R2014b (for details, see this Graphics Changes in R2014b PDF from MathWorks). I try to modify these pages and examples as needed, but they may not always reflect the latest changes. The following were first created in 2011 and updated using MATLAB R2016a.
Loyola peeps: There are many other examples on the H-drive!
The following pages have lots of examples. They are pages generated by MATLAB through the "publish html" feature. Not every type of command is explained completely or even shown.
- Plotting 2D functions
- Plotting parametric equations and vector functions (2D and 3D) plus fine-tuning plots
- Plotting 3D surfaces
- Using different coordinate systems
- Colors in MATLAB 2D and 3D plots
Useful and common commands for creating different 2D and 3D plots (not a complete list!)
xlabel('x-axis label'), ylabel('y-axis label'), etc.
plot3(x,y,z, 'r:')will create a red graph with dotted line.
plot3(x,y,z, 'k', 'LineWidth', 2)will make the line black and thicker
xlim([-2,2]), zlim([-10,10]), etc. can set the limit for the axes
axis([xmin, xmax, ymin, ymax, zmin, zmax])can set limits all at once for all axes
axis equal, axis tight, axis square, etc.
legend('legend 1', 'legend 2', ...)