core.py 文件源码

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

项目:hydro 作者: hydrogeog 项目源码 文件源码
def plot(self, title='Rating Curve', log=True):
        """ plot the rating curve """
        fig = plt.figure()
        ax1 = fig.add_subplot(111, facecolor=[.95,.95,.95])
        plt.grid(True, which='both', color='w', ls='-', zorder=0)
        ax1.scatter(self.stage, self.discharge, color='k', s=10)
        ax1.set_ylabel(r'Discharge, cfs')
        ax1.set_xlabel(r'Stage, ft')
        if log:
            ax1.set_ylim(0.01, 100)
            ax1.set_yscale('log'); ax1.set_xscale('log')                              # log scale x and y
            ax1.yaxis.set_major_formatter(FuncFormatter(lambda y,pos: ('{{:.{:1d}f}}'.format(int(np.maximum(-np.log10(y),0)))).format(y)))
            ax1.xaxis.set_major_formatter(FuncFormatter(lambda y,pos: ('{{:.{:1d}f}}'.format(int(np.maximum(-np.log10(y),0)))).format(y)))
        plt.title(title)
        ax1.set_axisbelow(True)         # puts grid below plot

        # write the equation in the plot
        ax1.text(0.05, 0.7, f'y = {self.popt[0]:.3f}x^{self.popt[1]:.3f}',
                 fontsize=15, transform=ax1.transAxes)
        # draw the model line
        line = np.linspace(min(self.stage), max(self.stage), 100)
        ax1.plot(line, exp_curve(line, self.popt[0], self.popt[1]), color='k')
        plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号