Python matplotlib.pyplot 模块,axhspan() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用matplotlib.pyplot.axhspan()

项目:githubgraph    作者:0x0FFF    | 项目源码 | 文件源码
def draw_timeline(self):
        plt.axhspan(0.97, 0.98, 0.1, 0.9, facecolor='#808080', linewidth=0)
        for year in range(2006, 2017):
            plt.text(0.1 + 0.75*(year-2006)/10.0, 0.96,
                     "%d" % year,
                     size = 10,
                     weight='bold',
                     color='white',
                     horizontalalignment='left',
                     verticalalignment='top',
                     transform=plt.gca().transAxes)
        cur = self.current_date * self.ticks_in_week + self.tick
        top = len(self.dates) * self.ticks_in_week
        pos = 0.1 + 0.8 * (float(cur) / float(top))
        plt.axvline(pos, 0.963, 0.987, color='orange', linewidth=3)
        plt.text(0.95, 0.01, "http://0x0fff.com",
                 size=8,
                 weight='bold',
                 style='italic',
                 color='white',
                 horizontalalignment='center',
                 transform=plt.gca().transAxes)
        return
项目:PyCS    作者:COSMOGRAIL    | 项目源码 | 文件源码
def runsimplot(self):
        """
        Viz of the MC results
        """

        tdmin = self.iniest.td - 3.0*self.iniest.tderr
        tdmax = self.iniest.td + 3.0*self.iniest.tderr

        fig = plt.figure(figsize=(6, 3))
        fig.subplots_adjust(top=0.95, bottom=0.2)
        plt.scatter(self.simtruedelays, self.simmesdelays - self.simtruedelays)
        plt.xlim(tdmin, tdmax)
        plt.xlabel("True delay [day]")
        plt.ylabel("Measurement error [day]")
        plt.axvline(self.iniest.td - self.iniest.tderr, color="gray", linestyle="-", zorder=20)
        plt.axvline(self.iniest.td + self.iniest.tderr, color="gray", linestyle="-", zorder=20)
        plt.axhline(0, color="black", linestyle="-", zorder=20)
        plt.axhline(- self.iniest.tderr, color="gray", linestyle="-", zorder=20)
        plt.axhline(+ self.iniest.tderr, color="gray", linestyle="-", zorder=20)
        plt.axhspan(-self.outest.tderr, self.outest.tderr, xmin=0, xmax=1, lw=0, color="red", alpha=0.2)
        #plt.ylim(- 2.0*self.iniest.tderr, + 2.0*self.iniest.tderr)


        plt.figtext(0.15, 0.8, "Total/initial error ratio: %.2f" % self.totalratio)

        #ax = plt.gca()
        #plt.figtext(0.15, 0.8, "Intrinsic/initial error ratio: %.2f" % self.intrinsicratio)
        #plt.axvline(self.iniest.td - self.iniest.tderr, color="gray", linestyle="-", zorder=20)
        #plt.axvline(self.iniest.td + self.iniest.tderr, color="gray", linestyle="-", zorder=20)
        #plt.axvline(self.outest.td, color="red", linestyle="-", zorder=20)

        plt.savefig(os.path.join(self.plotdir, "measvstrue.png"))
        plt.close()