You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/horizontal-bar-charts.md
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -109,8 +109,15 @@ fig.add_trace(go.Bar(
109
109
fig.update_layout(barmode='stack')
110
110
fig.show()
111
111
```
112
-
# 1. Example Horizontal Bar Chart (Facet)
112
+
### Small multiple horizontal bar charts show each component's size more clearly than a stacked bar
113
+
114
+
Bar charts with multiple components pose a fundamental trade off between presenting the total clearly and presenting the component values clearly. This small multiples approach shows the component magnitudes clearly at the cost of slightly obscuring the totals. A stacked bar does the opposite. Small multiple bar charts often work better in a horizontal orientation; and are easy to create with the px.bar orientation and facet_col parameters.
115
+
116
+
.
117
+
118
+
```
113
119
import pandas as pd
120
+
import plotly.express as px
114
121
115
122
data = {
116
123
"Quarter": ["Q1", "Q2", "Q3", "Q4"] * 3,
@@ -119,32 +126,35 @@ data = {
119
126
}
120
127
df = pd.DataFrame(data)
121
128
122
-
import plotly.express as px
123
129
124
130
fig = px.bar(
125
131
df,
126
132
x="Outcome",
127
133
y="Region",
128
134
orientation="h",
129
135
facet_col="Quarter",
130
-
title="Quarterly Number of Patients Served by Region",
136
+
title="Number of Patients Served by Region and Quarter",
0 commit comments