In a nutshell, either use the context manager, as mentioned by @Valentin, or call plt.rcdefaults() afterwards.
What happens when the rc parameters change to plt.xkcd() (which basically works).
plt.xkcd() saves the current parameters. rc returns a context manager (so you can use the with statement), which resets them at the end. If you did not save the context manager returned by plt.xkcd() , then you cannot return to the same rc parameters that you had before.
In other words, let's say you did something like plt.rc('lines', linewidth=2, color='r') before calling plt.xkcd() . If you did not do with plt.xkcd(): or manager = plt.xkcd() , then the state of rcParams after calling plt.rc will be lost.
However, you can revert to the standard rcParams by calling plt.rcdefaults() . You simply do not save any specific changes that you made before calling plt.xkcd() .
Joe kington
source share