Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Swap X and Y Axis in Excel Charts

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To change the x and y axis in Excel, you need to switch which data series is plotted on the horizontal (x) axis and which is plotted on the vertical (y) axis. The quickest way is to use the 'Select Data' option, then use the 'Switch Row/Column' button, or manually edit the axis references. This guide walks you through both methods, plus how to handle common issues like non-numeric x-axis data and reversed axes.

What You'll Need

  • An Excel workbook with a chart already created (column, bar, line, or scatter chart).
  • The source data that the chart is based on (usually in a range of cells).
  • Excel for Windows, Mac, or Excel Online. The steps are similar, but menu labels may differ slightly by version.

Step-by-Step

Method 1: Use Switch Row/Column (Quickest)

  1. Click on your chart to select it. This will bring up the 'Chart Tools' tab in the ribbon (on Windows) or the 'Chart Design' tab (on Mac).
  2. Look for the 'Data' group in the ribbon. You should see a button labeled 'Switch Row/Column' (or an icon with two arrows crossing). Click it.
  3. Excel will immediately swap the data series and the categories. The x-axis will now show what was previously the y-axis values, and vice versa.
  4. If the chart doesn't look right after switching, you can click 'Switch Row/Column' again to revert the change.

Note: This method works best when your data is laid out in a simple grid where the first row and first column contain labels. If your data is more complex, you may need to use Method 2.

Method 2: Manually Edit Axis References (More Control)

  1. Right-click on the chart and choose 'Select Data...' from the context menu. Alternatively, click the chart, then go to the 'Chart Design' tab and click 'Select Data' in the 'Data' group.
  2. In the 'Select Data Source' dialog box, you'll see two sections: 'Legend Entries (Series)' on the left and 'Horizontal (Category) Axis Labels' on the right.
  3. To swap the axes, you need to edit what each section refers to. Click on the 'Edit' button under 'Horizontal (Category) Axis Labels'.
  4. In the 'Axis Labels' dialog, clear the 'Axis label range' box and then select the cells that contain the values you want to appear on the x-axis. For example, if your original x-axis used A2:A10 and your y-axis used B2:B10, you would now select B2:B10 here. Click 'OK'.
  5. Now click on the 'Edit' button under 'Legend Entries (Series)'.
  6. In the 'Edit Series' dialog, you'll see a 'Series values' box. Clear it and select the cells that should now be the y-axis values (the original x-axis data). Click 'OK'.
  7. Click 'OK' again to close the 'Select Data Source' dialog. Your chart will update with the new axis assignments.

Method 3: For Scatter Charts (X-Y Plots)

Scatter charts are different because they treat both axes as value axes. If you have a scatter chart and want to swap the x and y data, you can do this:

  1. Right-click on the chart and select 'Select Data'.
  2. In the 'Legend Entries (Series)' section, click on your series and then click 'Edit'.
  3. In the 'Edit Series' dialog, you'll see 'X values' and 'Y values' fields. Swap the ranges between these two fields.
  4. Click 'OK' and then 'OK' again.

Common Mistakes

  • Not selecting the right data range: When manually editing, it's easy to accidentally include the header row or extra columns. Make sure your ranges match exactly.
  • Using 'Switch Row/Column' on a scatter chart: This button often does nothing or produces unexpected results on scatter charts. Use Method 3 instead.
  • Confusing axis labels with data series: In a column chart, the x-axis usually shows categories (like months or names), and the y-axis shows values. Swapping them might make your chart unreadable if you have many categories.
  • Forgetting to update the chart title: After swapping axes, the chart title may no longer describe what's shown. Edit the title to reflect the new orientation.

Tips

  • Use a bar chart for long category names: If your x-axis labels are long, consider using a bar chart (which is a column chart with swapped axes) instead of manually swapping. It's often more readable.
  • Check your data layout first: Excel's default behavior depends on whether your data is in rows or columns. If your data is in columns, Excel will usually plot the first column as x-axis labels. If your data is in rows, it will use the first row. Understanding this helps you predict what will happen.
  • Use 'Select Data' for fine-tuning: The 'Select Data' dialog is powerful. You can reorder series, add new ones, and edit axis labels all in one place.
  • Consider using a PivotChart: If your data is in a pivot table, you can swap axes by dragging fields between the 'Axis' and 'Legend' areas in the PivotChart Fields pane.

Troubleshooting

Why doesn't 'Switch Row/Column' work?

This button only works if your chart is a standard chart type (like column, bar, line, or pie) and if your data is structured in a way that Excel can interpret. For scatter charts, it won't work. Also, if you have multiple series, switching may not give you the result you expect. In that case, use Method 2 or 3.

My x-axis values are numbers, but Excel is treating them as categories.

This is common. To fix it, right-click on the x-axis, select 'Format Axis', and under 'Axis Options', check the 'Text axis' or 'Date axis' options. If you want a true numeric x-axis, you might need to change your chart type to a scatter chart.

After swapping, my chart looks like a mess.

If the chart becomes unreadable, it's likely because the new x-axis has too many categories or the data ranges are mismatched. Undo the change (Ctrl+Z) and double-check your data selection. Make sure the number of x-axis labels matches the number of data points in each series.

My axes are reversed (high values at bottom, low at top).

If you want to flip the order of an axis, right-click on the axis, select 'Format Axis', and check the 'Values in reverse order' box. This is useful for bar charts where you want the largest value at the top.

I can't find the 'Select Data' option.

On Excel for Mac, it's under the 'Chart Design' tab. On Excel Online, it's under the 'Chart' tab that appears when you click the chart. If you still can't find it, try right-clicking on the chart and looking for 'Select Data' in the context menu.

Frequently Asked Questions

Can I swap axes on a pie chart?

No, pie charts don't have axes. They display a single data series as slices. If you want to compare two sets of values, use a different chart type.

Will swapping axes change my underlying data?

No, swapping axes only changes how the data is displayed in the chart. Your original cell values remain untouched.

How do I make the x-axis show dates instead of numbers?

If your data contains dates, Excel may automatically recognize them. If not, right-click the axis, choose 'Format Axis', and under 'Axis Options', select 'Date axis'. You may need to ensure your date cells are formatted as dates.

What if I have multiple series? Can I swap only one?

Yes, you can edit each series individually using the 'Select Data' dialog. For each series, you can change its 'Series values' and the 'Horizontal Axis Labels' to point to different ranges.

Why does my x-axis show numbers as 1, 2, 3 instead of my labels?

This usually happens when you manually entered numbers as series names instead of using cell references. In the 'Select Data' dialog, click 'Edit' on the series and make sure the 'Series name' refers to a cell containing the label, not a literal number.

Can I set a different scale for the x-axis?

Yes, for value axes (like in scatter charts), you can right-click the axis, choose 'Format Axis', and set minimum, maximum, and major unit values. For category axes, you can only change the interval between labels.