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


Python pyplot.fignum_exists方法代码示例

本文整理汇总了Python中matplotlib.pyplot.fignum_exists方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.fignum_exists方法的具体用法?Python pyplot.fignum_exists怎么用?Python pyplot.fignum_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.fignum_exists方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_figure

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def test_figure(self):
        writer = SummaryWriter()

        figure, axes = plt.figure(), plt.gca()
        circle1 = plt.Circle((0.2, 0.5), 0.2, color='r')
        circle2 = plt.Circle((0.8, 0.5), 0.2, color='g')
        axes.add_patch(circle1)
        axes.add_patch(circle2)
        plt.axis('scaled')
        plt.tight_layout()

        writer.add_figure("add_figure/figure", figure, 0, close=False)
        assert plt.fignum_exists(figure.number) is True

        writer.add_figure("add_figure/figure", figure, 1)
        assert plt.fignum_exists(figure.number) is False

        writer.close() 
开发者ID:lanpa,项目名称:tensorboardX,代码行数:20,代码来源:test_figure.py

示例2: test_figure_list

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def test_figure_list(self):
        writer = SummaryWriter()

        figures = []
        for i in range(5):
            figure = plt.figure()
            plt.plot([i * 1, i * 2, i * 3], label="Plot " + str(i))
            plt.xlabel("X")
            plt.xlabel("Y")
            plt.legend()
            plt.tight_layout()
            figures.append(figure)

        writer.add_figure("add_figure/figure_list", figures, 0, close=False)
        assert all([plt.fignum_exists(figure.number) is True for figure in figures])

        writer.add_figure("add_figure/figure_list", figures, 1)
        assert all([plt.fignum_exists(figure.number) is False for figure in figures])

        writer.close() 
开发者ID:lanpa,项目名称:tensorboardX,代码行数:22,代码来源:test_figure.py

示例3: redraw

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def redraw(self):
        """
        Redraw plot. Use after custom user modifications of axes & fig objects
        """
        if plt.isinteractive():
            fig = self.kwargs['fig']
            #Redraw figure if it was previously closed prior to updating it
            if not plt.fignum_exists(fig.number):
                fig.show()
            fig.canvas.draw()
        else:
            print('redraw() is unsupported in non-interactive plotting mode!') 
开发者ID:HamsterHuey,项目名称:easyplot,代码行数:14,代码来源:easyplot.py

示例4: test_fignum_exists

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def test_fignum_exists():
    # pyplot figure creation, selection and closing with fignum_exists
    plt.figure('one')
    plt.figure(2)
    plt.figure('three')
    plt.figure()
    assert plt.fignum_exists('one')
    assert plt.fignum_exists(2)
    assert plt.fignum_exists('three')
    assert plt.fignum_exists(4)
    plt.close('one')
    plt.close(4)
    assert not plt.fignum_exists('one')
    assert not plt.fignum_exists(4) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:16,代码来源:test_figure.py

示例5: is_open

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def is_open(self) -> bool:
        """Returns True if the figure window is open."""
        return plt.fignum_exists(self.fig.number) 
开发者ID:google-research,项目名称:robel,代码行数:5,代码来源:plotting.py

示例6: display

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def display(self, image):
        if self.imsh is None or not plt.fignum_exists(self.imsh.figure.number):
            self.imsh = plt.imshow(image, interpolation='nearest')
            self.imsh.axes.axis('off')
            self.imsh.axes.set_position((0, 0, 1, 1))
            self.imsh.figure.canvas.draw()
        else:
            self.imsh.set_data(image)
        plt.pause(1e-4) 
开发者ID:crowsonkb,项目名称:style_transfer,代码行数:11,代码来源:display_image.py

示例7: plot_process

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def plot_process(queue,
                     name,
                     labels=None,
                     x_scale='linear',
                     y_scale='linear'):
        """Grabs data from the queue and plots it in a named figure
        """
        # Set up the figure and display it
        fig = setup_figure(name)
        plt.show(block=False)
        if labels is not None:
            plt.xlabel(labels[0])
            plt.ylabel(labels[1])
        plt.xscale(x_scale)
        plt.yscale(y_scale)

        while True:
            # Get all the data currently on the queue
            data = []
            while not queue.empty():
                data.append(queue.get())

            # If there is no data, no need to plot, instead wait for a
            # while
            if len(data) == 0 and plt.fignum_exists(fig.number):
                plt.pause(0.015)
                continue

            # Check if poison pill (None) arrived or the figure was closed
            if None in data or not plt.fignum_exists(fig.number):
                # If yes, close the figure and leave the process
                plt.close(fig)
                break
            else:
                # Plot the data, then wait 15ms for the plot to update
                for datum in data:
                    plt.plot(*datum[0], **datum[1])
                plt.pause(0.015) 
开发者ID:duerrp,项目名称:pyexperiment,代码行数:40,代码来源:plot.py

示例8: test_log_mpl_plotly

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fignum_exists [as 别名]
def test_log_mpl_plotly(self):
        assert (
            os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.CHART))
            is False
        )
        assert (
            os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.CHART))
            is False
        )

        figure, axes = plt.figure(), plt.gca()
        circle1 = plt.Circle((0.2, 0.5), 0.2, color="r")
        circle2 = plt.Circle((0.8, 0.5), 0.2, color="g")
        axes.add_patch(circle1)
        axes.add_patch(circle2)
        plt.axis("scaled")
        plt.tight_layout()

        with patch("polyaxon.tracking.run.Run._log_has_events") as log_dashboard:
            self.run.log_mpl_plotly_chart(name="figure", figure=figure, step=1)
        assert log_dashboard.call_count == 1

        self.event_logger.flush()
        assert (
            os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.CHART))
            is False
        )
        assert (
            os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.CHART))
            is True
        )
        events_file = get_event_path(
            self.run_path, kind=V1ArtifactKind.CHART, name="figure"
        )
        assert os.path.exists(events_file) is True
        results = V1Events.read(kind="image", name="figure", data=events_file)
        assert len(results.df.values) == 1

        with patch("polyaxon.tracking.run.Run._log_has_events") as log_dashboard:
            self.run.log_mpl_plotly_chart(name="figure", figure=figure, step=2)
        assert log_dashboard.call_count == 1
        assert plt.fignum_exists(figure.number) is False

        self.event_logger.flush()
        assert (
            os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.CHART))
            is False
        )
        assert (
            os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.CHART))
            is True
        )
        events_file = get_event_path(
            self.run_path, kind=V1ArtifactKind.CHART, name="figure"
        )
        assert os.path.exists(events_file) is True
        results = V1Events.read(kind="image", name="figure", data=events_file)
        assert len(results.df.values) == 2 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:60,代码来源:test_run_tracking.py


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