Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resetting default fonts/colours for plots in Python/Matplotlib

First time here and newbie so please bear with me.

I'm following along a data viz tutorial with matplotlib. I'm getting the same results (go me) but the font used (in the plot legend in particular) and the default co lours are different and no parameter has been set to change them. And of course the tutorial's stuff looks much nicer. I don't know why this happens but I'm thinking that maybe I did change some of the stuff in unrelated notebooks and those choices stuck. If so, how do I "reset" please?

I am not allowed to attach screenshots yet. Basically, my plot lines are light blue and orange while his are the traditional discrete dark blue and green. My legend font looks like bad excel while his looks like LateX.

Thank you for your suggestions.

like image 515
Chris Cuny Avatar asked Jul 18 '26 13:07

Chris Cuny


1 Answers

To find all the built in matplotlib themes, use

plt.style.available

I think the normal one is 'default'. So add this before you make your plots:

plt.style.use(['default'])

But you can make your plots look even better than the tutorial by using some of the other ones.

like image 171
Liam Keeley Avatar answered Jul 21 '26 03:07

Liam Keeley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!