Issue 20

matplotlib.use causes trouble if %matplotlib ... was used before.

Solution

Switch from use to switch_backend, suggested by @krumnack.

Snippets


In [ ]:
# Provided by @JarnoRFB (working example)
import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook
plt.rcParams['image.cmap'] = 'gray'

from cvloop import cvloop
cvloop()

In [ ]:
# Provided by @JarnoRFB (failing example)
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['image.cmap'] = 'gray'

from cvloop import cvloop
cvloop()

In [ ]:
# Provided by @krumnack (working example)
import matplotlib.pyplot as plt
plt.switch_backend('nbAgg')
from cvloop import cvloop
cvloop()

In [ ]:
# Provided by @krumnack (failing example)
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('nbAgg', warn=False, force=True)
from cvloop import cvloop
cvloop()

In [ ]:
# Provided by @JarnoRFB (failing example / next three cells)

In [ ]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [ ]:
img = np.random.randint(0, 255, size=900)
img.resize((30, 30))
plt.imshow(img)

In [ ]:
from cvloop import cvloop
cvloop()