Radiation.py 文件源码

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

项目:und_Sophie_2016 作者: SophieTh 项目源码 文件源码
def plot(self,title="",label=""):
        import matplotlib.pyplot as plt
        from mpl_toolkits.mplot3d import Axes3D

        if self.distance == None:
            zlabel = "Flux (phot/s/0.1%bw/mrad2)"
            xlabel = 'X [rad]'
            ylabel = 'Y [rad]'
        else:
            zlabel = "Flux (phot/s/0.1%bw/mm2)"
            xlabel = 'X [m]'
            ylabel = 'Y [m]'

        if self.X is None or self.Y is None:
            raise Exception(" X and Y must be array for plotting")
        if self.X.shape != self.Y.shape:
            raise Exception(" X and Y must have the same shape")
        fig = plt.figure()
        if len(self.X.shape) ==2 :
            ax = Axes3D(fig)
            ax.plot_surface(self.X, self.Y, self.intensity, rstride=1, cstride=1,cmap='hot_r')
        else :
            ax = fig.gca(projection='3d')
            ax.plot(self.X, self.Y, self.intensity, label=label)
            ax.legend()
        ax.set_xlabel(xlabel)
        ax.set_ylabel(ylabel)
        ax.set_zlabel(zlabel)

        plt.title(title)
        plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号