当前位置: 首页>>代码示例>>Python>>正文


Python Gcf.get_fig_manager方法代码示例

本文整理汇总了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)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:backend_webagg.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:backend_pdf.py

示例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()) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:23,代码来源:backend_webagg.py

示例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()) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:23,代码来源:backend_webagg.py

示例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()) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:23,代码来源:backend_webagg.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:backend_webagg.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:backend_webagg.py

示例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) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:8,代码来源:backend_webagg.py

示例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) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:16,代码来源:backend_webagg.py

示例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 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:33,代码来源:backend_pdf.py

示例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) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:30,代码来源:backend_pdf.py


注:本文中的matplotlib._pylab_helpers.Gcf.get_fig_manager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。