Advanced Plotting Earlier in the class we saw how to create basic line and scatter plots. MATLAB can also plot 3-d surfaces, bar and pie charts, etc. To make a 3d plot of a set of (x,y,z) data points, call: plot3(x,y,z,LineSpec) LineSpec is optional, same options as a regular plot command Often want to visualize a surface of the form z = f(x,y) Need the equivalent of many closely spaced x-values we used when plotting in 2-d [X, Y] = meshgrid(x,y) - creates a 2-d rectangular grid with x coordinates defined by x and y coordinates defined by y Can visualize this using scatter (creates a scatter plot) Contour plot - Visualizes 3-d info in 2-d Each contour has the same function value at each point contour(X,Y,Z) or contour(X,Y,Z,n) X and Y are the coordinates from meshgrid. Z is the function values at those points. If n is set, it defines the number of contours to be plotted. Why is this a reasonable visualization? Show standard quadratic plot without line connecting points contour3(X,Y,Z) or contour3(X,Y,Z,n) Same as contour but contours are drawn at cooresponding Z level mesh(X, Y, Z) Creates a "wire frame", color helps illustrate the function value surf(X, Y, Z) Creates a 3-d surface plot subplot(rows, cols, loc) - creates rows-by-cols matrix of plot areas and makes loc the current one meshc – combination mesh/contour plot meshz – 3-D mesh with curtain surfc – combination surface/contour plot Bar plots bar - standard bar plot barh - horizontal bar plot bar3 - 3d bar plot Histograms hist(X, N) – histogram for elements of X into N bins, or N = vec of bin center values Pie Charts pie(X) – pie chart of data in X, values are normalized via X/sum(X), can "explode" pieces pie3(X) – 3-D pie chart