當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。