Skip to content

Commit

Permalink
Fixed backend loading if a backend is loaded (Google Collab) and back…
Browse files Browse the repository at this point in the history
…end to use on MacOSX
  • Loading branch information
backtrader committed May 28, 2020
1 parent 73e20f9 commit 5cbc8ff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backtrader/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import sys


try:
import matplotlib
except ImportError:
raise ImportError(
'Matplotlib seems to be missing. Needed for plotting support')
else:
matplotlib.use('TkAgg')
touse = 'TKAgg' if sys.platform != 'darwin' else 'MacOSX'
try:
matplotlib.use(touse)
except:
# if another backend has already been loaded, an exception will be
# generated and this can be skipped
pass


from .plot import Plot, Plot_OldSync
Expand Down

0 comments on commit 5cbc8ff

Please sign in to comment.