How to Graph Multiple Data Points in MATLAB

Written by chris daniels
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Graph Multiple Data Points in MATLAB
MATLAB allows you to plot multiple sets of points simultaneously. (Thinkstock/Comstock/Getty Images)

The technical programming language MATLAB allows you to create complex, presentation-quality graphs. For clarity, it is often preferred to display multiple sets of points on the same axes for comparison. However, by default, many MATLAB functions for plotting data overwrite the graph in the current figure. MATLAB contains a "hold" function, allowing new graphs to be added to a figure on the same set of axes.

Skill level:


  1. 1

    Plot your first set of points using the "plot" function. By default, the plot function plots a 2-D line. Use the "LineStyle" option, setting it to the value "none," and specify the "Marker" to a value other than "none," the default. For example, to plot a set of random points with no line and blue open circle markers:


  2. 2

    Prevent MATLAB from overwriting the current figure, using the command "hold on."

  3. 3

    Use the "plot" function or other graphing function to add another graph to the current set of axes. Be sure to specify a different marker style to differentiate multiple data sets. To add a second set of points with red squares:


  4. 4

    Enter the command "hold off" to return MATLAB to defaults and prevent other graphs from being added to your finished figure.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.