当前位置: 首页>>代码示例>>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方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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"}')
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:9,代码来源:backend_webagg.py

示例2: 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)
     self.set_header(
         'Content-Type', mimetypes.types_map.get(fmt, 'binary'))
     buff = BytesIO()
     manager.canvas.figure.savefig(buff, format=fmt)
     self.write(buff.getvalue())
开发者ID:QuLogic,项目名称:matplotlib,代码行数:10,代码来源:backend_webagg.py

示例3: 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"], "mpl_interface.js")) as fd:
                tpl = fd.read()

            fignum = int(fignum)
            manager = Gcf.get_fig_manager(fignum)

            t = tornado.template.Template(tpl)
            self.write(t.generate(toolitems=NavigationToolbar2WebAgg.toolitems, canvas=manager.canvas))
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:11,代码来源:backend_webagg.py

示例4: send_image

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
 def send_image(self):
     canvas = Gcf.get_fig_manager(self.fignum).canvas
     diff = canvas.get_diff_image()
     if self.supports_binary:
         self.write_message(diff, binary=True)
     else:
         data_uri = "data:image/png;base64,{0}".format(
             diff.encode('base64').replace('\n', ''))
         self.write_message(data_uri)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:11,代码来源:backend_webagg.py

示例5: 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:
         canvas = Gcf.get_fig_manager(self.fignum).canvas
         canvas.handle_event(message)
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:12,代码来源:backend_webagg.py

示例6: get

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
        def get(self):
            manager = Gcf.get_fig_manager(1)
            canvas = manager.canvas

            self.set_header('Content-Type', 'application/javascript')

            self.render(
                "mpl_interface.js",
                toolitems=NavigationToolbar2WebAgg.toolitems,
                canvas=canvas)
开发者ID:kcrisman,项目名称:matplotlib,代码行数:12,代码来源:backend_webagg.py

示例7: 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(
                    os.path.dirname(__file__),
                    'web_backend', 'index.html')) as fd:
                tpl = fd.read()

            fignum = int(fignum)
            manager = Gcf.get_fig_manager(fignum)

            t = tornado.template.Template(tpl)
            self.write(t.generate(
                toolitems=NavigationToolbar2WebAgg.toolitems,
                canvas=manager.canvas))
开发者ID:BrenBarn,项目名称:matplotlib,代码行数:15,代码来源:backend_webagg.py

示例8: 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:Aharobot,项目名称:matplotlib,代码行数:16,代码来源:backend_webagg.py

示例9: 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

        try:
            orig_canvas = figure.canvas
            figure.canvas = FigureCanvasPgf(figure)

            width, height = figure.get_size_inches()
            if self._n_figures == 0:
                self._write_header(width, height)
            else:
                # \pdfpagewidth and \pdfpageheight exist on pdftex, xetex, and
                # luatex<0.85; they were renamed to \pagewidth and \pageheight
                # on luatex>=0.85.
                self._file.write(
                    br'\newpage'
                    br'\ifdefined\pdfpagewidth\pdfpagewidth'
                    br'\else\pagewidth\fi=%ain'
                    br'\ifdefined\pdfpageheight\pdfpageheight'
                    br'\else\pageheight\fi=%ain'
                    b'%%\n' % (width, height)
                )

            figure.savefig(self._file, format="pgf", **kwargs)
            self._n_figures += 1
        finally:
            figure.canvas = orig_canvas
开发者ID:endolith,项目名称:matplotlib,代码行数:51,代码来源:backend_pgf.py

示例10: 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:AdamHeck,项目名称:matplotlib,代码行数:19,代码来源:backend_webagg.py

示例11: 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']
     elif message['type'] == 'ack':
         # Network latency tends to decrease if traffic is
         # flowing in both directions.  Therefore, the browser
         # sends back an "ack" message after each image frame
         # is received.  This could also be used as a simple
         # sanity check in the future, but for now the
         # performance increase is enough to justify it, even
         # if the server does nothing with it.
         pass
     else:
         canvas = Gcf.get_fig_manager(self.fignum).canvas
         canvas.handle_event(message)
开发者ID:kcrisman,项目名称:matplotlib,代码行数:21,代码来源:backend_webagg.py

示例12: get

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
        def get(self, fmt):
            fignum = int(fignum)
            manager = Gcf.get_fig_manager(fignum)

            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 = io.BytesIO()
            manager.canvas.print_figure(buff, format=fmt)
            self.write(buff.getvalue())
开发者ID:bmu,项目名称:webagg_examples,代码行数:22,代码来源:plot_server.py

示例13: 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

        try:
            orig_canvas = figure.canvas
            figure.canvas = FigureCanvasPgf(figure)

            width, height = figure.get_size_inches()
            if self._n_figures == 0:
                self._write_header(width, height)
            else:
                self._file.write(self._build_newpage_command(width, height))

            figure.savefig(self._file, format="pgf", **kwargs)
            self._n_figures += 1
        finally:
            figure.canvas = orig_canvas
开发者ID:souravsingh,项目名称:matplotlib,代码行数:41,代码来源:backend_pgf.py

示例14: 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:kcrisman,项目名称:matplotlib,代码行数:4,代码来源:backend_webagg.py

示例15: on_close

# 需要导入模块: from matplotlib._pylab_helpers import Gcf [as 别名]
# 或者: from matplotlib._pylab_helpers.Gcf import get_fig_manager [as 别名]
 def on_close(self):
     manager = Gcf.get_fig_manager(self.fignum)
     if manager is not None:
         manager.remove_web_socket(self)
开发者ID:Aharobot,项目名称:matplotlib,代码行数:6,代码来源:backend_webagg.py


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