本文整理汇总了Python中matplotlib._pylab_helpers.Gcf.get_fig_manager方法的典型用法代码示例。如果您正苦于以下问题:Python Gcf.get_fig_manager方法的具体用法?Python Gcf.get_fig_manager怎么用?Python Gcf.get_fig_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib._pylab_helpers.Gcf
的用法示例。
在下文中一共展示了Gcf.get_fig_manager方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def get(self, fignum):
with open(os.path.join(WebAggApplication._mpl_dirs['web_backend'],
'single_figure.html')) as fd:
tpl = fd.read()
fignum = int(fignum)
manager = Gcf.get_fig_manager(fignum)
ws_uri = 'ws://{req.host}{prefix}/'.format(req=self.request,
prefix=self.url_prefix)
t = tornado.template.Template(tpl)
self.write(t.generate(
prefix=self.url_prefix,
ws_uri=ws_uri,
fig_id=fignum,
toolitems=NavigationToolbar2WebAgg.toolitems,
canvas=manager.canvas))
示例2: savefig
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def savefig(self, figure=None, **kwargs):
"""
Save the Figure instance *figure* to this file as a new page.
If *figure* is a number, the figure instance is looked up by
number, and if *figure* is None, the active figure is saved.
Any other keyword arguments are passed to Figure.savefig.
"""
if isinstance(figure, Figure):
figure.savefig(self, format='pdf', **kwargs)
else:
if figure is None:
figureManager = Gcf.get_active()
else:
figureManager = Gcf.get_fig_manager(figure)
if figureManager is None:
raise ValueError("No such figure: " + repr(figure))
else:
figureManager.canvas.figure.savefig(self, format='pdf', **kwargs)
示例3: get
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def get(self, fignum, fmt):
fignum = int(fignum)
manager = Gcf.get_fig_manager(fignum)
# TODO: Move this to a central location
mimetypes = {
'ps': 'application/postscript',
'eps': 'application/postscript',
'pdf': 'application/pdf',
'svg': 'image/svg+xml',
'png': 'image/png',
'jpeg': 'image/jpeg',
'tif': 'image/tiff',
'emf': 'application/emf'
}
self.set_header('Content-Type', mimetypes.get(fmt, 'binary'))
buff = BytesIO()
manager.canvas.figure.savefig(buff, format=fmt)
self.write(buff.getvalue())
示例4: get
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def get(self, fignum, fmt):
fignum = int(fignum)
manager = Gcf.get_fig_manager(fignum)
# TODO: Move this to a central location
mimetypes = {
'ps': 'application/postscript',
'eps': 'application/postscript',
'pdf': 'application/pdf',
'svg': 'image/svg+xml',
'png': 'image/png',
'jpeg': 'image/jpeg',
'tif': 'image/tiff',
'emf': 'application/emf'
}
self.set_header('Content-Type', mimetypes.get(fmt, 'binary'))
buff = six.BytesIO()
manager.canvas.print_figure(buff, format=fmt)
self.write(buff.getvalue())
示例5: get
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def get(self, fignum, fmt):
fignum = int(fignum)
manager = Gcf.get_fig_manager(fignum)
# TODO: Move this to a central location
mimetypes = {
'ps': 'application/postscript',
'eps': 'application/postscript',
'pdf': 'application/pdf',
'svg': 'image/svg+xml',
'png': 'image/png',
'jpeg': 'image/jpeg',
'tif': 'image/tiff',
'emf': 'application/emf'
}
self.set_header('Content-Type', mimetypes.get(fmt, 'binary'))
buff = six.BytesIO()
manager.canvas.figure.savefig(buff, format=fmt)
self.write(buff.getvalue())
示例6: open
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def open(self, fignum):
self.fignum = int(fignum)
manager = Gcf.get_fig_manager(self.fignum)
manager.add_web_socket(self)
_, _, w, h = manager.canvas.figure.bbox.bounds
manager.resize(w, h)
self.on_message('{"type":"refresh"}')
if hasattr(self, 'set_nodelay'):
self.set_nodelay(True)
示例7: on_close
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def on_close(self):
Gcf.get_fig_manager(self.fignum).remove_web_socket(self)
示例8: open
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def open(self, fignum):
self.fignum = int(fignum)
self.manager = Gcf.get_fig_manager(self.fignum)
self.manager.add_web_socket(self)
if hasattr(self, 'set_nodelay'):
self.set_nodelay(True)
示例9: on_message
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def on_message(self, message):
message = json.loads(message)
# The 'supports_binary' message is on a client-by-client
# basis. The others affect the (shared) canvas as a
# whole.
if message['type'] == 'supports_binary':
self.supports_binary = message['value']
else:
manager = Gcf.get_fig_manager(self.fignum)
# It is possible for a figure to be closed,
# but a stale figure UI is still sending messages
# from the browser.
if manager is not None:
manager.handle_json(message)
示例10: savefig
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def savefig(self, figure=None, **kwargs):
"""
Saves a :class:`~matplotlib.figure.Figure` to this file as a new page.
Any other keyword arguments are passed to
:meth:`~matplotlib.figure.Figure.savefig`.
Parameters
----------
figure : :class:`~matplotlib.figure.Figure` or int, optional
Specifies what figure is saved to file. If not specified, the
active figure is saved. If a :class:`~matplotlib.figure.Figure`
instance is provided, this figure is saved. If an int is specified,
the figure instance to save is looked up by number.
"""
if not isinstance(figure, Figure):
if figure is None:
manager = Gcf.get_active()
else:
manager = Gcf.get_fig_manager(figure)
if manager is None:
raise ValueError("No figure {}".format(figure))
figure = manager.canvas.figure
# Force use of pdf backend, as PdfPages is tightly coupled with it.
try:
orig_canvas = figure.canvas
figure.canvas = FigureCanvasPdf(figure)
figure.savefig(self, format="pdf", **kwargs)
finally:
figure.canvas = orig_canvas
示例11: savefig
# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
def savefig(self, figure=None, **kwargs):
"""
Saves a :class:`~matplotlib.figure.Figure` to this file as a new page.
Any other keyword arguments are passed to
:meth:`~matplotlib.figure.Figure.savefig`.
Parameters
----------
figure: :class:`~matplotlib.figure.Figure` or int, optional
Specifies what figure is saved to file. If not specified, the
active figure is saved. If a :class:`~matplotlib.figure.Figure`
instance is provided, this figure is saved. If an int is specified,
the figure instance to save is looked up by number.
"""
if isinstance(figure, Figure):
figure.savefig(self, format='pdf', **kwargs)
else:
if figure is None:
figureManager = Gcf.get_active()
else:
figureManager = Gcf.get_fig_manager(figure)
if figureManager is None:
raise ValueError("No such figure: " + repr(figure))
else:
figureManager.canvas.figure.savefig(self, format='pdf',
**kwargs)