2

I'm working on a project with Python and saw a nice plot on Kaggle, but the language used is R, which I don't know.

Test Data: kaggle: Monthly Electricity Production in GWh [2010-2022]

Plot on Kaggle:

plot on Kaggle

I tried to recreate the plot using Python and I think I'm really close to it.

Plot I created:

plot I created

grid = sns.FacetGrid(data=breakdown, col="country", col_wrap=7, height=3, aspect=1, sharex=True, sharey=False)
grid.map_dataframe(sns.pointplot, x="value", y="product", hue="year", join=False, markers=["o", "*"])
grid.set_titles("{col_name}")
grid.set_axis_labels("[%]", "")
grid.set(xlim=(0, 100), ylim=(-0.5, 2.5))
grid.despine(right=True, top=True)
grid.add_legend(loc="upper left", frameon=False)

I'd like to connect the points as she did and add colors for each category (Nuclear, Renewables, and Fossil fuels). How can I do that?

Here is a sample of the breakdown dataset I used to reproduce the plot:

,country,year,product,value
0,Australia,2010,Renewables,10.400785746199682
12,Australia,2022,Renewables,34.742331289873064
467,Australia,2022,Nuclear,0.0
455,Australia,2010,Nuclear,0.0
910,Australia,2010,Fossil fuels,89.59921045031392
922,Australia,2022,Fossil fuels,65.25766871012695
13,Austria,2010,Renewables,67.75576873959946
25,Austria,2022,Renewables,78.76446322617821
480,Austria,2022,Nuclear,0.0
468,Austria,2010,Nuclear,0.0
923,Austria,2010,Fossil fuels,32.24423569765363
935,Austria,2022,Fossil fuels,21.235536776894953
493,Belgium,2022,Nuclear,45.295925696472636
481,Belgium,2010,Nuclear,49.984697658490894
948,Belgium,2022,Fossil fuels,27.7838958679145
38,Belgium,2022,Renewables,26.9201784290824
26,Belgium,2010,Renewables,8.396529615422356
936,Belgium,2010,Fossil fuels,41.61877381915019
494,Canada,2010,Nuclear,14.608937138869305
949,Canada,2010,Fossil fuels,22.769913684560386
961,Canada,2022,Fossil fuels,17.25003004705112
51,Canada,2022,Renewables,69.86121900236432
39,Canada,2010,Renewables,62.62114900575948
506,Canada,2022,Nuclear,12.888750950897817

0 Answers0