Graphics Previous page   Next Page

Plotting Steps

The process of constructing a basic graph to meet your presentation graphics requirements is outlined in the following table. The table shows seven typical steps and some example code for each.

If you are performing analysis only, you may want to view various graphs just to explore your data. In this case, steps 1 and 3 may be all you need. If you are creating presentation graphics, you may want to fine-tune your graph by positioning it on the page, setting line styles and colors, adding annotations, and making other such improvements.

Step
Typical Code
  1. Prepare your data


x = 0:0.2:12;
y1 = bessel(1,x);
y2 = bessel(2,x);
y3 = bessel(3,x);
  1. Select a window and position a plot region within the window
figure(1)
subplot(2,2,1)
  1. Call elementary plotting function
h = plot(x,y1,x,y2,x,y3);
  1. Select line and marker characteristics
set(h,'LineWidth',2,{'LineStyle'},{'--';':';'-.'})
set(h,{'Color'},{'r';'g';'b'})
  1. Set axis limits, tick marks, and grid lines
axis([0 12 -0.5 1])
grid on
  1. Annotate the graph with axis labels, legend, and text
xlabel('Time')
ylabel('Amplitude')
legend(h,'First','Second','Third')
title('Bessel Functions')
[y,ix] = min(y1);
text(x(ix),y,'First Min \rightarrow',...
             'HorizontalAlignment','right')
  1. Export graph
print -depsc -tiff -r200 myplot


Previous page  Basic Plotting Commands Creating Line Plots Next page

© 1994-2005 The MathWorks, Inc.