Reputation: 2751
Let's say I have 2 Matplotlib Figures at the same time that are updated in a for loop. One of the Figures (let's say fig0
has images, while fig1
is a line plot). I would like fig0
to have the standard Matplotlib style while in fig1
I would like to set plt.style.use('ggplot')
for fig1
.
So far I have tried this:
plt.style.use('ggplot')
fig0 = plt.figure(0)
fig1 = plt.figure(1)
for i in range(10):
# print stuff in both figures
But this sets ggplot
style in both Figures (as expected). I could not find the way to separately set style in each Figure.
Upvotes: 4
Views: 1255
Reputation: 876
This would solve it, except for the loop.
import matplotlib.pyplot as plt
with plt.style.context('ggplot'):
plt.figure(0)
plt.plot([3,2,1])
with plt.style.context('default'):
plt.figure(1)
plt.plot([1,2,3])
plt.show()
You'd probably be better off without the loop anyway... as long the loop isn't absolutely necessary for some reason. Just keep whatever you're adding to the plots in the loop in lists and modify the example above.
Upvotes: 2