How do I fix the legend labels losing colour in a seaborn barplot?

As shown, my plot legend has lost its colour after renaming labels:

How do I fix this?

Your code so far
https://replit.com/@jaimeggb/boilerplate-page-view-time-series-visualizer#time_series_visualizer.py

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Challenge: Page View Time Series Visualizer

Link to the challenge:

Maybe you’ve moved on by now, but if you still need a fix…
If you add this code at the beginning…
fig, ax = plt.subplots()

and then, after defining your plot…

hands, labs = ax.get_legend_handles_labels()
plt.legend(handles=hands, labels=labs)

That should establish the colours in the legend.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.