garrettj403 / SciencePlots

Matplotlib styles for scientific plotting
MIT License
6.98k stars 701 forks source link

Use SciencePlots in Google Colab #28

Closed Julian-J-S closed 3 years ago

Julian-J-S commented 3 years ago

I was trying to get this to work in Google Colab for some hours until I found the solution. Unlike the desktop you have to reload the style libraries to recognize and use the new *.mplstyle files.

!pip install SciencePlots
import matplotlib.pyplot as plt
plt.style.reload_library() # <<<<<<<<<<
plt.style.use(['science', 'no-latex'])

Maybe you can add this in the README under Installation if someone else wants to use SciencePlots in Google Colab and encounters the problem. Thanks! Great library!

garrettj403 commented 3 years ago

Hi @JulianCologne

Thank you for pointing that out. I've added that information to the README (under the FAQ section).

Cheers!

garrettj403 commented 3 years ago

Addressed in commit bd677fdebaec8c4ae49a422ad5a4c90328a4f069

garrettj403 commented 3 years ago

I've also added matplotlib.style.reload_library() to the end of the installation function in setup.py (see commit 657b860).

garrettj403 commented 3 years ago

Unfortunately, plt.style.reload_library() doesn't seem to help at all when it is added to setup.py.

You will still need to use plt.style.reload_library() in your Google Colab document.