Show Sidebar Hide Sidebar

Stacked Bar Charts

A bar chart with segments to break down and compare different parts within each bar's data group.

Step 1

Try an Example

Before getting started with your own dataset, you can check out an example. First, select the 'Type' menu. Hovering the mouse over the chart type icon will display three options: 1) Charts like this by Plotly users, 2) View tutorials on this chart type, and, 3) See a basic example.

Clicking the 'See a basic example' option will show what a sample chart looks like after adding data and editing with the style. You'll also see what labels and style attributes were selected for this specific chart, as well as the end result.

Example after

You can also use the data featured in this tutorial by clicking on 'Open This Data in Plotly' on the left-hand side. It'll open in Chart Studio.

Step 2

Add Your Data to Plotly

Head to Plotly’s Chart Studio and add your data. You have the option of typing directly in the grid, uploading your file, or entering the URL of an online dataset. Plotly accepts .xls, .xlsx, or .csv files. For more information on how to enter your data, see this tutorial.

Step 3

Create a Chart

After adding data, go to the 'Traces' section under the 'Structure' menu on the left-hand side. Choose the 'Type' of trace, then choose 'Scatter' under 'Simple' chart type.

Choose chart main

Next, select 'X' and 'Y' values from the dropdown menus. This will create a bar trace, as seen below.

Adding x and y axis

Then, choose the desired orientation for the bar trace. 'Vertical' is chosen for this example.

To add more traces to the plot, click on '+ Trace' button at the top right corner of the panel in the 'Traces' section under the 'Structure' menu.

Trace open

Add as many traces as needed, until the plot is complete! Now, we have a raw bar chart, as seen below.

Finished traces

Step 4

Style a Chart

The 'Style' menu displays many options to modify characteristics of the overall chart layout or the individual traces. To see more options about styling the chart, visit the style and layout section of the Chart Studio documentation.

To change the properties of the bar traces, such as trace name, bar color, or size and spacing, go to the 'Traces' section under the 'Style' menu.

Bar Properties

Note that updating the trace name will update the legends as well.

Trace Name

To make this bar chart a stacked bar chart, go to the property 'Barmode' under 'Bar Size and Spacing' and select 'Stack' as the bar mode from the dropdown list.

Stacked chart

To set the plot title, go to the 'General' section under the 'Style' menu and type in the plot title within the textbox provided under 'Title'.

Plot Title

To set the axes title, go to the 'Axes' section under the 'Style' menu, choose the desired axis tab on the top, and type in the respective axis title within the textbox provided.

Axes Title

Another approach is to click and then enter the titles directly on the plot interface. The same can be done for the legends.

Type directly title

Step 5

Save and Share

To save the plot, click the 'Save' button on the left-hand side. A save modal will appear, as seen below, where you can specify the filenames and privacy settings for your plot and data grid.

Save main

For more information on privacy settings and how sharing works, visit Plotly's sharing tutorial.

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to our Premium or Enterprise plans.