How to label a matlab plot

Written by michael peter
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to label a matlab plot
Plot labels describe what each axis of the plot is representing. (Thinkstock/Comstock/Getty Images)

MATLAB is a technical computing software used by scientists and engineers for data processing and analysis. After analysis is complete, MATLAB offers plotting options to assist in visualising the data. Aside from plotting the data, it is important to properly label a graph to explain what each axis portrays. Labels that can be included within a plot include those for the x and y-axis, a plot title and a legend to match the line colour with the data it represents.

Skill level:
Moderately Easy


  1. 1

    Clear all active variables within the workspace by entering "clear all" in the Command window.

  2. 2

    Generate sample data to plot. Input "x=1:1:20" and "y=rand(1,20)" into the Command window which outputs an array of 20 equally spaced numbers starting at 1 and ending at 20 for the x-axis and an array of 20 randomly generated numbers for the y-data.

  3. 3

    Plot the data generated in step 2 by inputting "plot(x, y)" in the Command window.

  4. 4

    Select "Show Plot Tools and Dock Figure" under the "Figure" menu.

  5. 5

    Click anywhere in the plot window. Under the "Title" box, input the name of the plot. In the "X Axis" menu, input under the "X Label" the name of the x-axis. Do the same for the y-axis by selecting the "Y Axis" menu.

  6. 6

    Select each newly created label to change the font of the text.

  7. 7

    Insert a legend to the graph by selecting "Insert-Legend" from the "Figure" menu.

Tips and warnings

  • Plot labels can also be created within the Command window by inputting "plot(x,y); xlabel('xname'); ylabel('yname');" where "xname" and "yname" are the labels of the x and y-axis, respectively.

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.