本文整理汇总了Python中matplotlib.backend_bases.FigureManagerBase方法的典型用法代码示例。如果您正苦于以下问题:Python backend_bases.FigureManagerBase方法的具体用法?Python backend_bases.FigureManagerBase怎么用?Python backend_bases.FigureManagerBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backend_bases
的用法示例。
在下文中一共展示了backend_bases.FigureManagerBase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib import backend_bases [as 别名]
# 或者: from matplotlib.backend_bases import FigureManagerBase [as 别名]
def __init__(self, canvas, num):
backend_bases.FigureManagerBase.__init__(self, canvas, num)
self.web_sockets = set()
self.toolbar = self._get_toolbar(canvas)
示例2: __init__
# 需要导入模块: from matplotlib import backend_bases [as 别名]
# 或者: from matplotlib.backend_bases import FigureManagerBase [as 别名]
def __init__(self, canvas, num):
backend_bases.FigureManagerBase.__init__(self, canvas, num)
self.set_window_title("Figure %d" % num)
self.toolbar = NavigationToolbar2Wasm(canvas)
示例3: run_code
# 需要导入模块: from matplotlib import backend_bases [as 别名]
# 或者: from matplotlib.backend_bases import FigureManagerBase [as 别名]
def run_code(code, code_path, ns=None, function_name=None):
"""
Import a Python module from a path, and run the function given by
name, if function_name is not None.
"""
# Change the working directory to the directory of the example, so
# it can get at its data files, if any. Add its path to sys.path
# so it can import any helper modules sitting beside it.
pwd = os.getcwd()
if setup.config.plot_working_directory is not None:
try:
os.chdir(setup.config.plot_working_directory)
except OSError as err:
raise OSError(str(err) + '\n`plot_working_directory` option in'
'Sphinx configuration file must be a valid '
'directory path')
except TypeError as err:
raise TypeError(str(err) + '\n`plot_working_directory` option in '
'Sphinx configuration file must be a string or '
'None')
elif code_path is not None:
dirname = os.path.abspath(os.path.dirname(code_path))
os.chdir(dirname)
with cbook._setattr_cm(
sys, argv=[code_path], path=[os.getcwd(), *sys.path]), \
contextlib.redirect_stdout(StringIO()):
try:
code = unescape_doctest(code)
if ns is None:
ns = {}
if not ns:
if setup.config.plot_pre_code is None:
exec('import numpy as np\n'
'from matplotlib import pyplot as plt\n', ns)
else:
exec(str(setup.config.plot_pre_code), ns)
if "__main__" in code:
ns['__name__'] = '__main__'
# Patch out non-interactive show() to avoid triggering a warning.
with cbook._setattr_cm(FigureManagerBase, show=lambda self: None):
exec(code, ns)
if function_name is not None:
exec(function_name + "()", ns)
except (Exception, SystemExit) as err:
raise PlotError(traceback.format_exc())
finally:
os.chdir(pwd)
return ns