I would like to toggle my plot between two different styles. But I'm having a problem finding out how to change the style after the plot is created.
import matplotlib.pyplot as plt
plt.style.use("dark_background") # create plot in dark format
fig, (axes1, axes2) = plt.subplots(2)
axes1.plot(range(5))
axes2.plot(range(4, -1, -1))
"""other code here"""
if True: # condintion for changing style later
plt.style.use("default") # depending on code, change plot style back
plt.show()
If using the plt.style.use function doesn't work, is it possible using the rcParams?
.set_color()and similar functions. Best use the style in a context,with plt.style.context('dark_background'):