I'm trying to think of a way to most effectively display the following analysis. I'm using Python and Plotly for other analysis and would like to stick with that.
Say I have a number of newspapers. Each newspaper has a different amount of circulation worldwide. Within that, some percentage of the circulation is from the US. And within that, some percentage is from a given state, say, California.
I'd like to have a bar graph that shows, for one journal:
- Total circulation (say, 1M)
- Of that, how much is US circluation (say, 500k)
- Of that, how much is from California (say 100k)
So I want a compact way to show
- What percentage of total is from US (50%)
- What percentage of US is from CA (20%)
- What percentage of total is from CA (10%)
Then repeat for each journal and look for trends.
Plotly has a stacked bar chart which looks close, but I want to customize to specifically call out the three percentages. Each newspaper has a different total number, so a stacked bar chart normalized to 100% won't tell me the magnitude of each different newspaper.
I was thinking total %'s on the left of the bar, and US-specific %'s on the right of the bar. Or different colors?
Any advice is appreciated.
---Edit to add MWE---
import pandas as pd
import plotly.express as px
data = {'Name':['Paper A', 'Paper B'],
'Total circ':[1000000, 800000],
'US circ':[500000, 200000],
'CA':[100000, 100000]
}
df = pd.DataFrame.from_dict(data)
df['not CA'] = df['US circ'] - df['CA']
df['not US'] = df['Total circ'] - df['US circ']
fig = px.bar(df, x='Name', y=['not US', 'not CA', 'CA'], text_auto=True)