I've looked around on here and googling in general, but I can't find what should be a clean answer.
So, I have table [ A ], which is a timeseries, broken down by country, and table [ B ] , which is a list of those countries ranked.
The default order of the legend appears to be alphabetical, however, I'd like to use Table [ B ] values to order the legend in the table [ A ] plot.
Is this possible?
Image link as I am not yet 'ranked' . Screencap of chart+legend vs ideal ordered list
Code :
fig, ax = plt.subplots()
for label, grp in cht_table.groupby('Country'):
grp.plot(x = 'Date', y = 'moving',ax = ax,figsize=(15,10),label=label )
Sample data :
TABLE A ------ Time Series ----
Date Country moving
2020-01-24 Argentina 0.0
2020-01-25 Argentina 0.0
2020-01-26 Argentina 0.0
2020-01-27 Argentina 0.0
2020-01-28 Argentina 0.0
TABLE B ------ Ranking ----
Country
0 US
1 Brazil
2 India
3 Mexico
4 Peru
5 Russia
6 United Kingdom
7 Italy
8 France
9 Colombia
10 Argentina
11 Germany
12 Iran
13 Spain
14 Poland