I struggle with this: I try to represent the same data monthly with a bar chart and the total with a pie chart but I can't get the same color representing the same category on both graphs. My code looks like:
import pandas as pd
import plotly.express as px
from plotly.offline import plot
df = pd.read_csv('myfile.csv')
data = df.groupby(['month', 'category']).size().reset_index(name='number of records')
histo = px.bar(data, x='month', y='number of records', color='category', barmode='stack')
pie = px.pie(data, values='number of records', names='category')
plot(histo, filename = 'histo')
plot(pie, filename = 'pie')
And the result is:
As we can see A is blue on bar chart while X is blue on pie chart.
Can anyone helps?
Tks