What are axis labels on a graph

Return to Charts Home

This tutorial will explain how to add Axis Labels on the X & Y Axis in Excel and Google Sheets

How to Add Axis Labels (X&Y) in Excel

Graphs and charts in Excel are a great way to visualize a dataset in a way that is easy to understand. The user should be able to understand every aspect about what the visualization is trying to show right away. As a result, including labels to the X and Y axis is essential so that the user can see what is being measured in the graph.

Excel offers several different charts and graphs to show your data. In this example, we are going to show a line graph that shows revenue for a company over a five-year period. In the below example, you can see how essential labels are because in this below graph, the user would have trouble understanding the amount of revenue over this period. Is the revenue in 2016 $15, $15,000, etc.? This is a common example that shows why labeling the axis is necessary in creating graphs.

Adding Axis Labels

To add labels:

  1. Click on the Graph
  2. Click the + Sign
  3. Check Axis Titles

You will then see “Axis Title” next to both axes.

Edit Chart Axis Labels

  1. Click the Axis Title
  2. Highlight the old axis labels
  3. Type in your new axis name

Make sure the Axis Labels are clear, concise, and easy to understand.

Dynamic Axis Titles

To make your Axis titles dynamic, enter a formula for your chart title

  1. Click on the Axis Title you want to change
  2. In the Formula Bar, put in the formula for the cell you want to reference (In this case, we want the axis title “Revenue” in Cell C2”). Click Enter.

How to Add Axis Labels (X&Y) in Google Sheets

Adding Axis Labels

  1. Double Click on your Axis
  2. Select Charts & Axis Titles

3. Click on the Axis Title you want to Change (Horizontal or Vertical Axis)

4. Type in your Title Name

Axis Labels Provide Clarity

Once you change the title for both axes, the user will now better understand the graph. For example, there is no longer confusion as to whether the revenue is showing in thousands, millions, billions, etc. The axis label has now made it clear that the total revenue is in millions. This is a common example as it helps to make the graph look cleaner.

As you can see, axis labels are easy and important to add so that the information that is being visualized is clear at first glance. When presenting graphs to a user, first impressions are key in order to help the visualizations stand out and be easily understood in a short period of time.

This example shows how to add a title and axis labels to a chart by using the title, xlabel, and ylabel functions. It also shows how to customize the appearance of the axes text by changing the font size.

Create x as 100 linearly spaced values between -2π and . Create y1 and y2 as sine and cosine values of x. Plot both sets of data.

x = linspace(-2*pi,2*pi,100); y1 = sin(x); y2 = cos(x); figure plot(x,y1,x,y2)

Add Title

Add a title to the chart by using the title function. To display the Greek symbol π, use the TeX markup, \pi.

title('Line Plot of Sine and Cosine Between -2\pi and 2\pi')

Add Axis Labels

Add axis labels to the chart by using the xlabel and ylabel functions.

xlabel('-2\pi < x < 2\pi') ylabel('Sine and Cosine Values')

Add Legend

Add a legend to the graph that identifies each data set using the legend function. Specify the legend descriptions in the order that you plot the lines. Optionally, specify the legend location using one of the eight cardinal or intercardinal directions, in this case, 'southwest'.

legend({'y = sin(x)','y = cos(x)'},'Location','southwest')

Change Font Size

Axes objects have properties that you can use to customize the appearance of the axes. For example, the FontSize property controls the font size of the title, labels, and legend.

Access the current Axes object using the gca function. Then use dot notation to set the FontSize property.

ax = gca; ax.FontSize = 13;

Alternatively, starting in R2022a, you can change the font size of the axes text by using the fontsize function.

Title with Variable Value

Include a variable value in the title text by using the num2str function to convert the value to text. You can use a similar approach to add variable values to axis labels or legend entries.

Add a title with the value of sin(π)/2.

k = sin(pi/2); title(['sin(\pi/2) = ' num2str(k)])

See Also

title | xlabel | ylabel | legend | linspace | fontsize

Related Topics

  • Specify Axis Limits
  • Specify Axis Tick Values and Labels

Última postagem

Tag