plots.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pymchelper 作者: DataMedSci 项目源码 文件源码
def _save_2d_error_plot(self, detector, xlist, ylist, elist, x_axis_label, y_axis_label, z_axis_label):
        import matplotlib
        matplotlib.use('Agg')
        import matplotlib.pyplot as plt
        from matplotlib import colors

        # configure logscale on X and Y axis (both for positive and negative numbers)

        fig, ax = plt.subplots(1, 1)

        if PlotAxis.x in self.axis_with_logscale:
            plt.xscale('symlog')
        if PlotAxis.y in self.axis_with_logscale:
            plt.yscale('symlog')

        if PlotAxis.z in self.axis_with_logscale:
            norm = colors.LogNorm(vmin=elist[elist > 0].min(), vmax=elist.max())
        else:
            norm = colors.Normalize(vmin=elist.min(), vmax=elist.max())

        plt.xlabel(x_axis_label)
        plt.ylabel(y_axis_label)

        mesh = plt.pcolormesh(xlist, ylist, elist.clip(0.0), cmap=self.colormap, norm=norm)
        cbar = fig.colorbar(mesh)
        cbar.set_label(label=z_axis_label, rotation=270, verticalalignment='bottom')

        base_name, _ = os.path.splitext(self.plot_filename)
        plt.savefig(base_name + "_error.png")
        plt.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号