Exemple #1
0
 def __init__(self,
              dirname,
              outdir,
              prefix,
              suffix,
              quiet=False,
              figure=None):
     #Set up the plotting figure
     if figure is None:
         self.figure = pylab.figure()
     else:
         self.figure = figure
     #Can do prefixes if we want to all the filenames
     if prefix:
         prefix += "_"
     #We have an output directory, a prefix, base filename (which is overridden by subclasses)
     #And a suffix (file type)
     self.outfile = "{0}/{1}{2}.{3}".format(outdir, prefix, self.filename,
                                            suffix)
     #All the data will be in subclasses of this
     self.dirname = dirname
     self.quiet = quiet
Exemple #2
0
    def make_2d_plot(self, name1, name2):
        #Get the data
        if 'planck' in self.source.name.lower():

            def smooth_likelihood(obj, x, y):
                n = obj.options.get("n_kde", 100)
                factor = obj.options.get("factor_kde", 2.0)
                kde = KDE([x, y], factor=factor)
                x_range = (x.min(), x.max())
                y_range = (y.min(), y.max())
                (x_axis,
                 y_axis), like = kde.grid_evaluate(n, [x_range, y_range])
                return n, x_axis, y_axis, like

            x = self.reduced_col(name1)
            y = self.reduced_col(name2)

        else:
            if name1[-2:] == 's8':
                omm = self.reduced_col('cosmological_parameters--omega_m')
                sigma_8 = self.reduced_col('cosmological_parameters--sigma_8')
                x = sigma_8 * (omm / 0.3)**0.5
            else:
                x = self.find_or_pad(name1)
            if name2[-2:] == 's8':
                omm = self.reduced_col('cosmological_parameters--omega_m')
                sigma_8 = self.reduced_col('cosmological_parameters--sigma_8')
                y = sigma_8 * (omm / 0.3)**0.5
            else:
                y = self.find_or_pad(name2)

        if x.max() - x.min() == 0 or y.max() - y.min() == 0:
            return
        print "  (making %s vs %s)" % (name1, name2)

        #import pdb ; pdb.set_trace()

        #Interpolate using KDE
        try:
            n, x_axis, y_axis, like = self.smooth_likelihood(x, y)
        except:
            try:
                n, x_axis, y_axis, like = self.smooth_likelihood_noweight(x, y)
            except:

                def smooth_likelihood(obj, x, y):
                    n = 100
                    factor = 2.0
                    kde = KDE([x, y], factor=factor)
                    x_range = (x.min(), x.max())
                    y_range = (y.min(), y.max())
                    (x_axis,
                     y_axis), like = kde.grid_evaluate(n, [x_range, y_range])
                    return n, x_axis, y_axis, like

                n, x_axis, y_axis, like = smooth_likelihood(self, x, y)

        figure, filename = self.figure("2D", name1, name2)

        #Choose levels at which to plot contours

        contour1 = 1 - 0.68
        contour2 = 1 - 0.95
        try:
            level1, level2, total_mass = self._find_contours(
                like, x, y, n, x_axis[0], x_axis[-1], y_axis[0], y_axis[-1],
                contour1, contour2)
        except:

            def find_contours(like, x, y, n, xmin, xmax, ymin, ymax, contour1,
                              contour2):
                N = len(x)
                x_axis = np.linspace(xmin, xmax, n + 1)
                y_axis = np.linspace(ymin, ymax, n + 1)
                histogram, _, _ = np.histogram2d(x, y, bins=[x_axis, y_axis])

                def objective(limit, target):
                    w = np.where(like >= limit)
                    count = histogram[w]
                    return count.sum() - target

                target1 = histogram.sum() * (1 - contour1)
                target2 = histogram.sum() * (1 - contour2)

                level1 = scipy.optimize.bisect(objective,
                                               like.min(),
                                               like.max(),
                                               args=(target1, ))
                level2 = scipy.optimize.bisect(objective,
                                               like.min(),
                                               like.max(),
                                               args=(target2, ))
                return level1, level2, like.sum()

            level1, level2, total_mass = find_contours(like, x, y, n,
                                                       x_axis[0], x_axis[-1],
                                                       y_axis[0], y_axis[-1],
                                                       contour1, contour2)
            #import pdb ; pdb.set_trace()
        level0 = 1.1
        levels = [level2, level1, level0]
        #Create the figure
        fig, filename = self.figure("2D", name1, name2)
        pylab.figure(fig.number)

        #Make the plot
        #pylab.figure(figure.number, figsize=(8,7))
        keywords = self.keywords_2d()
        fill = self.options.get("fill", True)
        if self.fill_list != None:
            fill = self.fill_list[self.source.index]
        imshow = self.imshow[self.source.index]
        #plot_points = self.options.get("plot_points", False)
        color = self.colors[self.source.index]
        linestyle = self.linestyles[self.source.index]
        if self.linecolors[self.source.index] is not None:
            linecolor = self.linecolors[self.source.index]
        else:
            linecolor = color
        print self.source.index, linecolor

        if self.opaque_list[self.source.index]:
            pylab.contourf(x_axis,
                           y_axis,
                           like.T, [level2, level0],
                           colors=['white'])
        print "fill", self.source.index, fill

        if imshow:
            pylab.imshow(like.T,
                         extent=(x_axis[0], x_axis[-1], y_axis[0], y_axis[-1]),
                         aspect='auto',
                         origin='lower',
                         cmap=cmap_white_to_color(color))
        elif fill:
            if self.fill_colors[self.source.index] is not None:
                c = self.fill_colors[self.source.index]
                pylab.contourf(x_axis,
                               y_axis,
                               like.T, [level2, level0],
                               colors=[c[0]])
                pylab.contourf(x_axis,
                               y_axis,
                               like.T, [level1, level0],
                               colors=[c[1]])
            else:
                pylab.contourf(x_axis,
                               y_axis,
                               like.T, [level2, level0],
                               colors=[color],
                               alpha=self.alphas[self.source.index])
                if self.opaque_centre[self.source.index]:
                    pylab.contourf(x_axis,
                                   y_axis,
                                   like.T, [level1, level0],
                                   colors=[color])
                else:
                    pylab.contourf(x_axis,
                                   y_axis,
                                   like.T, [level1, level0],
                                   colors=[color],
                                   alpha=self.alphas[self.source.index])
        if (not fill) or self.line_list[self.source.index]:
            print self.source.index, linecolor
            pylab.contour(x_axis,
                          y_axis,
                          like.T, [level2, level1],
                          colors=[linecolor],
                          linestyles=linestyle,
                          linewidths=self.linewidths[self.source.index])
            #if self.labels is not None:
            #    self.proxies.append(pylab.plot([],[], color=color, linestyle=linestyle, linewidth=self.linewidths[self.source.index])[0])
        if self.labels is not None:
            if self.fill_colors[self.source.index] is not None:
                print self.fill_colors[self.source.index]
            elif fill:
                print self.source.index, self.line_list[self.source.index]
                if self.line_list[self.source.index] is not None:
                    conv = matplotlib.colors.ColorConverter()
                    edgecolor = linecolor
                    self.proxies.append(
                        pylab.Line2D([0, 2.5], [0, 0],
                                     linestyle=linestyle,
                                     linewidth=3,
                                     color=linecolor))
                    #facecolor=conv.to_rgba(color,alpha=1-(1-self.alphas[self.source.index])**2)
                    #self.proxies.append(pylab.Rectangle((0,0),1,1,facecolor=facecolor,edgecolor=edgecolor))#,alpha=(1-(1-self.alphas[self.source.index])**2)))
                else:
                    self.proxies.append(
                        pylab.Rectangle(
                            (0, 0),
                            1,
                            1,
                            fc=color,
                            edgecolor=color,
                            alpha=(1 -
                                   (1 - self.alphas[self.source.index])**2)))
            else:
                self.proxies.append(
                    pylab.plot(
                        [], [],
                        color=color,
                        linestyle=linestyle,
                        linewidth=self.linewidths[self.source.index])[0])

        if self.plot_points is not None:
            point_markers = ['x', '+', '^']
            for p, m in zip(self.plot_points, point_markers):
                print p, m
                pylab.plot(p[0],
                           p[1],
                           m,
                           color='k',
                           markersize=10,
                           markerfacecolor='none')

        #Do the labels
        print self.proxies, self.labels
        if self.labels is not None:
            leg = pylab.legend(self.proxies,
                               self.labels,
                               loc="upper left",
                               fontsize=13)
            leg.get_frame().set_alpha(
                0.75)  # this will make the box totally transparent
            leg.get_frame().set_edgecolor(
                'white')  # this will make the edges of the
        pylab.ylabel(r"$A_\mathrm{IA}$", fontsize=30, fontname='serif')
        pylab.xlabel(r"$b_g$", fontsize=30, fontname='serif')
        pylab.tight_layout()
        for col, text in zip(self.colors, leg.get_texts()):
            text.set_color(col)
            if col == 'pink':
                text.set_color('hotpink')
        if blind:
            pylab.xticks(visible=False)
        pylab.xticks(visible=True, fontsize=25)
        pylab.yticks(visible=True, fontsize=25)
        pylab.xlim(self.axis[0], self.axis[1])
        pylab.ylim(self.axis[2], self.axis[3])
        pylab.title('$z=1.0$', fontsize=25)
        #       pylab.subplots_adjust(top=0.95)
        x0 = [4.6]
        dx = [0.5]
        y0 = [1.77]
        pylab.errorbar(x0,
                       y0,
                       xerr=dx,
                       yerr=[0.04],
                       markersize=9.0,
                       markerfacecolor='k',
                       color='k',
                       marker='*',
                       markeredgecolor='k',
                       linestyle='none')
        #  pylab.errorbar([4.35341365],[1.80416667], xerr=7.080459e-01, yerr=1.706998e-02,color='pink',marker='o')
        #pylab.title('$\gamma \gamma + \delta_g \gamma + \delta_g\delta_g$')
        #pylab.axhline(0,color="k",alpha=0.5,ls=':')
        #pylab.axhline(5.0,color="darkviolet",lw=1, ls="--")
        #print "Plotting bounds line..."
        return filename
Exemple #3
0
    def make_2d_plot(self, name1, name2):
          #Get the data
        x = self.reduced_col(name1)
        y = self.reduced_col(name2)


        if x.max()-x.min()==0 or y.max()-y.min()==0:
            return
        print "  (making %s vs %s)" % (name1, name2)


        #Interpolate using KDE
        try:
            n, x_axis, y_axis, like = self.smooth_likelihood(x, y)
        except np.linalg.LinAlgError:
            print "  -- these two parameters have singular covariance - probably a linear relation"
            print "Not making a 2D plot of them"
            return []

        figure,filename = self.figure("2D", name1, name2)

          #Choose levels at which to plot contours
        
        contour1=1-0.68
        contour2=1-0.95
        try: 
            level1, level2, total_mass = self._find_contours(like, x, y, n, x_axis[0], x_axis[-1], y_axis[0], y_axis[-1], contour1, contour2)
        except:
            import pdb ; pdb.set_trace()
        level0 = 1.1
        levels = [level2, level1, level0]
        #Create the figure
        fig,filename = self.figure("2D", name1, name2)
        pylab.figure(fig.number)

        #Make the plot
        #pylab.figure(figure.number, figsize=(8,7))
        keywords = self.keywords_2d()
        fill = self.options.get("fill", True)
        if self.fill_list!=None:
            fill = self.fill_list[self.source.index]
        imshow = self.imshow[self.source.index]
        #plot_points = self.options.get("plot_points", False)
        color = self.colors[self.source.index]
        linestyle = self.linestyles[self.source.index]
        if self.linecolors[self.source.index] is not None:
            linecolor=self.linecolors[self.source.index]
        else:
            linecolor=color
        print self.source.index,linecolor
        
        if self.opaque_list[self.source.index]:
            pylab.contourf(x_axis, y_axis, like.T, [level2,level0], colors=['white'])
        print "fill",self.source.index, fill

        if imshow:
            pylab.imshow(like.T, extent=(x_axis[0], x_axis[-1], y_axis[0], y_axis[-1]), aspect='auto', origin='lower', cmap=cmap_white_to_color(color))
        elif fill:
            if self.fill_colors[self.source.index] is not None:
                c=self.fill_colors[self.source.index]
                pylab.contourf(x_axis, y_axis, like.T, [level2,level0], colors=[c[0]])
                pylab.contourf(x_axis, y_axis, like.T, [level1,level0], colors=[c[1]])
            else:
                pylab.contourf(x_axis, y_axis, like.T, [level2,level0], colors=[color], alpha=self.alphas[self.source.index])
                if self.opaque_centre[self.source.index]:
                    pylab.contourf(x_axis, y_axis, like.T, [level1,level0], colors=[color])
                else:
                    pylab.contourf(x_axis, y_axis, like.T, [level1,level0], colors=[color], alpha=self.alphas[self.source.index])            
        if (not fill) or self.line_list[self.source.index]: 
            print self.source.index,linecolor
            pylab.contour(x_axis, y_axis, like.T, [level2,level1], colors=[linecolor], linestyles=linestyle, linewidths=self.linewidths[self.source.index])
            #if self.labels is not None:
            #    self.proxies.append(pylab.plot([],[], color=color, linestyle=linestyle, linewidth=self.linewidths[self.source.index])[0])
        if self.labels is not None:
            if self.fill_colors[self.source.index] is not None:
                print self.fill_colors[self.source.index]
            elif fill:
                print self.source.index,self.line_list[self.source.index]
                if self.line_list[self.source.index] is not None:                    
                    conv=matplotlib.colors.ColorConverter()
                    edgecolor=linecolor
                    facecolor=conv.to_rgba(color,alpha=1-(1-self.alphas[self.source.index])**2)
                    self.proxies.append(pylab.Rectangle((0,0),1,1,facecolor=facecolor,edgecolor=edgecolor))#,alpha=(1-(1-self.alphas[self.source.index])**2)))
                else:
                    self.proxies.append(pylab.Rectangle((0,0),1,1,fc=color,edgecolor=color,alpha=(1-(1-self.alphas[self.source.index])**2)))
            else:
                self.proxies.append(pylab.plot([],[], color=color, linestyle=linestyle, linewidth=self.linewidths[self.source.index])[0])

        if self.plot_points is not None:
            point_markers=['x','+','^']
            for p,m in zip(self.plot_points,point_markers):
                print p,m
                pylab.plot(p[0], p[1], m, color='k', markersize=10, markerfacecolor='none')

        #Do the labels
        print self.proxies,self.labels
        if self.labels is not None:
            leg=pylab.legend(self.proxies,self.labels,loc="upper right")
            leg.get_frame().set_alpha(0) # this will make the box totally transparent
            leg.get_frame().set_edgecolor('white') # this will make the edges of the 
        pylab.xlabel(self.latex(name1))
        pylab.ylabel(self.latex(name2))
        pylab.tight_layout()
        if self.axis is not None:
            pylab.axis(self.axis)
        return filename     
 def save(self):
     pylab.figure(self.figure.number)
     if not self.quiet: print("Saving ", self.outfile)
     pylab.savefig(self.outfile)
 def plot(self):
     pylab.figure(self.figure.number)
    def make_1d_plot(self, name1):
          #Get the data
        #import pdb ; pdb.set_trace()

        filename = self.filename(name1)
        col1 = self.source.get_col(name1)
        like = self.source.get_col("post")

        vals1 = np.unique(col1)
        n1 = len(vals1)
        like_sum = np.zeros(n1)

        #normalizing like this is a big help 
        #numerically
        like = like-like.max()

        #marginalize
        for k,v1 in enumerate(vals1):
            w = np.where(col1==v1)
            like_sum[k] = np.log(np.exp(like[w]).sum())
        like = like_sum.flatten()
        like -= like.max()


        #linearly interpolate
        n1_interp = n1*10
        vals1_interp = np.linspace(vals1[0], vals1[-1], n1_interp)
        like_interp = np.interp(vals1_interp, vals1, like)
        if np.isfinite(like_interp).any():
            vals1 = vals1_interp
            like = like_interp
            n1 = n1_interp
        else:
            print()
            print("Parameter %s has a very wide range in likelihoods " % name1)
            print("So I couldn't do a smooth likelihood interpolation for plotting")
            print()


        #normalize
        like[np.isnan(like)] = -np.inf
        like -= like.max()


        #Determine the spacing in the different parameters
        dx = vals1[1]-vals1[0]

        #Set up the figure
        fig,filename = self.figure(name1)
        pylab.figure(fig.number)

        #Plot the likelihood
        print('----------------------- HITTA',self.source.index, self.colors[self.source.index])
        pylab.plot(vals1, np.exp(like), linewidth=self.linewidths[self.source.index], label=self.labels[self.source.index], color=self.colors[self.source.index], linestyle='-')
        self.proxies.append(pylab.Line2D([0,2.5],[0,0], color=self.colors[self.source.index], linewidth=self.linewidths[self.source.index]))

        #Find the levels of the 68% and 95% contours
        X, L = self.find_edges(np.exp(like), 0.68, 0.95, vals1)
        #Plot black dotted lines from the y-axis at these contour levels
        for (x, l) in zip(X,L):
            if np.isnan(x[0]):
                continue
            pylab.plot([x[0],x[0]], [0, l[0]], ':', color='black')
            pylab.plot([x[1],x[1]], [0, l[1]], ':', color='black')

        #import pdb ; pdb.set_trace()

        if self.labels is not None:
            leg = pylab.legend(self.proxies,self.labels,loc="upper left", fontsize=16)
            leg.get_frame().set_alpha(0.75) # this will make the box totally transparent
            leg.get_frame().set_edgecolor('white') # this will make the edges of the 

        #Set the x and y limits
        pylab.ylim(0,1.05)
        pylab.yticks(visible=False)
        pylab.xticks(visible=True, fontsize=16)
        pylab.xlim(self.axis[0],self.axis[1])
        #Add label
        pylab.xlabel('$A_1$', fontsize=18)
        return filename
Exemple #7
0
    def make_2d_plot(self, name1, name2):
          #Get the data
        x = self.reduced_col(name1)
        y = self.reduced_col(name2)


        if x.max()-x.min()==0 or y.max()-y.min()==0:
            return
        print "  (making %s vs %s)" % (name1, name2)


        #Interpolate using KDE
        try:
            n, x_axis, y_axis, like = self.smooth_likelihood(x, y)
        except np.linalg.LinAlgError:
            print "  -- these two parameters have singular covariance - probably a linear relation"
            print "Not making a 2D plot of them"
            return []

        figure,filename = self.figure("2D", name1, name2)

          #Choose levels at which to plot contours
        
        contour1=1-0.68
        contour2=1-0.95
        try: 
            level1, level2, total_mass = self._find_contours(like, x, y, n, x_axis[0], x_axis[-1], y_axis[0], y_axis[-1], contour1, contour2)
        except:
            import pdb ; pdb.set_trace()
        level0 = 1.1
        levels = [level2, level1, level0]
        #Create the figure
        fig,filename = self.figure("2D", name1, name2)
        pylab.figure(fig.number)

        #Make the plot
        #pylab.figure(figure.number, figsize=(8,7))
        keywords = self.keywords_2d()
        fill = self.options.get("fill", True)
        if self.fill_list!=None:
            fill = self.fill_list[self.source.index]
        imshow = self.imshow[self.source.index]
        #plot_points = self.options.get("plot_points", False)
        color = self.colors[self.source.index]
        linestyle = self.linestyles[self.source.index]
        if self.linecolors[self.source.index] is not None:
            linecolor=self.linecolors[self.source.index]
        else:
            linecolor=color
        print self.source.index,linecolor
        
        if self.opaque_list[self.source.index]:
            pylab.contourf(x_axis, y_axis, like.T, [level2,level0], colors=['white'])
        print "fill",self.source.index, fill

        if imshow:
            pylab.imshow(like.T, extent=(x_axis[0], x_axis[-1], y_axis[0], y_axis[-1]), aspect='auto', origin='lower', cmap=cmap_white_to_color(color))
        elif fill:
            if self.fill_colors[self.source.index] is not None:
                c=self.fill_colors[self.source.index]
                pylab.contourf(x_axis, y_axis, like.T, [level2,level0], colors=[c[0]])
                pylab.contourf(x_axis, y_axis, like.T, [level1,level0], colors=[c[1]])
            else:
                pylab.contourf(x_axis, y_axis, like.T, [level2,level0], colors=[color], alpha=self.alphas[self.source.index])
                if self.opaque_centre[self.source.index]:
                    pylab.contourf(x_axis, y_axis, like.T, [level1,level0], colors=[color])
                else:
                    pylab.contourf(x_axis, y_axis, like.T, [level1,level0], colors=[color], alpha=self.alphas[self.source.index])            
        if (not fill) or self.line_list[self.source.index]: 
            print self.source.index,linecolor
            pylab.contour(x_axis, y_axis, like.T, [level2,level1], colors=[linecolor], linestyles=linestyle, linewidths=self.linewidths[self.source.index])
            #if self.labels is not None:
            #    self.proxies.append(pylab.plot([],[], color=color, linestyle=linestyle, linewidth=self.linewidths[self.source.index])[0])
        if self.labels is not None:
            if self.fill_colors[self.source.index] is not None:
                print self.fill_colors[self.source.index]
            elif fill:
                print self.source.index,self.line_list[self.source.index]
                if self.line_list[self.source.index] is not None:                    
                    conv=matplotlib.colors.ColorConverter()
                    edgecolor=linecolor
                    self.proxies.append(pylab.Line2D([0,2.5], [0,0], linestyle=linestyle, linewidth=3, color=linecolor))
                    #facecolor=conv.to_rgba(color,alpha=1-(1-self.alphas[self.source.index])**2)
                    #self.proxies.append(pylab.Rectangle((0,0),1,1,facecolor=facecolor,edgecolor=edgecolor))#,alpha=(1-(1-self.alphas[self.source.index])**2)))
                else:
                    self.proxies.append(pylab.Rectangle((0,0),1,1,fc=color,edgecolor=color,alpha=(1-(1-self.alphas[self.source.index])**2)))
            else:
                self.proxies.append(pylab.plot([],[], color=color, linestyle=linestyle, linewidth=self.linewidths[self.source.index])[0])

        if self.plot_points is not None:
            point_markers=['x','+','^']
            for p,m in zip(self.plot_points,point_markers):
                print p,m
                pylab.plot(p[0], p[1], m, color='k', markersize=10, markerfacecolor='none')

        #Do the labels
        print self.proxies,self.labels
        if self.labels is not None:
            leg=pylab.legend(self.proxies,self.labels,loc="upper right")
            leg.get_frame().set_alpha(0) # this will make the box totally transparent
            leg.get_frame().set_edgecolor('white') # this will make the edges of the 
        pylab.xlabel(r"$S_8 \equiv \sigma_8 \left( \Omega_\mathrm{m} / 0.3 \right )^{\frac{1}{2}}$",fontsize=22)
        pylab.ylabel("$A_\mathrm{IA}$", fontsize=22)
        pylab.tight_layout()
        if blind:
            pylab.xticks(visible=False)
            pylab.yticks(visible=False)
        np.random.seed(2007)
        dx = (np.random.rand()*2 - 1.0) * (0.4-1.2)*0.1
        
         
        #pylab.xticks(np.array([0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2])+dx,["0.4","0.5","0.6","0.7",'0.8','0.9','1.0','1.1','1.2'])
        #pylab.yticks(np.array([0.6,0.7,0.8,0.9,1.0])+d
        pylab.xlim(self.axis[0], self.axis[1])
        pylab.ylim(self.axis[2], self.axis[3])
        pylab.xlim(self.axis[0], self.axis[1])
        pylab.ylim(self.axis[2], self.axis[3])
        #pylab.axhline(5.0,color="darkviolet",lw=1, ls="--")
        #print "Plotting bounds line..."
        return filename     
    def make_2d_plot(self, name1, name2):
        #Get the data
        x = self.reduced_col(name1)
        y = self.reduced_col(name2)

        if x.max() - x.min() == 0 or y.max() - y.min() == 0:
            return
        print "  (making %s vs %s)" % (name1, name2)

        #Interpolate using KDE
        try:
            n, x_axis, y_axis, like = self.smooth_likelihood(x, y)
        except np.linalg.LinAlgError:
            print "  -- these two parameters have singular covariance - probably a linear relation"
            print "Not making a 2D plot of them"
            return []

        figure, filename = self.figure("2D", name1, name2)

        #Choose levels at which to plot contours

        contour1 = 1 - 0.68
        contour2 = 1 - 0.95
        try:
            level1, level2, total_mass = self._find_contours(
                like, x, y, n, x_axis[0], x_axis[-1], y_axis[0], y_axis[-1],
                contour1, contour2)
        except:
            import pdb
            pdb.set_trace()
        level0 = 1.1
        levels = [level2, level1, level0]
        #Create the figure
        fig, filename = self.figure("2D", name1, name2)
        pylab.figure(fig.number)

        #Make the plot
        #pylab.figure(figure.number, figsize=(8,7))
        keywords = self.keywords_2d()
        fill = self.options.get("fill", True)
        if self.fill_list != None:
            fill = self.fill_list[self.source.index]
        imshow = self.imshow[self.source.index]
        #plot_points = self.options.get("plot_points", False)
        color = self.colors[self.source.index]
        linestyle = self.linestyles[self.source.index]
        if self.linecolors[self.source.index] is not None:
            linecolor = self.linecolors[self.source.index]
        else:
            linecolor = color
        print self.source.index, linecolor

        if self.opaque_list[self.source.index]:
            pylab.contourf(x_axis,
                           y_axis,
                           like.T, [level2, level0],
                           colors=['white'])
        print "fill", self.source.index, fill

        if imshow:
            pylab.imshow(like.T,
                         extent=(x_axis[0], x_axis[-1], y_axis[0], y_axis[-1]),
                         aspect='auto',
                         origin='lower',
                         cmap=cmap_white_to_color(color))
        elif fill:
            if self.fill_colors[self.source.index] is not None:
                c = self.fill_colors[self.source.index]
                pylab.contourf(x_axis,
                               y_axis,
                               like.T, [level2, level0],
                               colors=[c[0]])
                pylab.contourf(x_axis,
                               y_axis,
                               like.T, [level1, level0],
                               colors=[c[1]])
            else:
                pylab.contourf(x_axis,
                               y_axis,
                               like.T, [level2, level0],
                               colors=[color],
                               alpha=self.alphas[self.source.index])
                if self.opaque_centre[self.source.index]:
                    pylab.contourf(x_axis,
                                   y_axis,
                                   like.T, [level1, level0],
                                   colors=[color])
                else:
                    pylab.contourf(x_axis,
                                   y_axis,
                                   like.T, [level1, level0],
                                   colors=[color],
                                   alpha=self.alphas[self.source.index])
        if (not fill) or self.line_list[self.source.index]:
            print self.source.index, linecolor
            pylab.contour(x_axis,
                          y_axis,
                          like.T, [level2, level1],
                          colors=[linecolor],
                          linestyles=linestyle,
                          linewidths=self.linewidths[self.source.index])
            #if self.labels is not None:
            #    self.proxies.append(pylab.plot([],[], color=color, linestyle=linestyle, linewidth=self.linewidths[self.source.index])[0])
        if self.labels is not None:
            if self.fill_colors[self.source.index] is not None:
                print self.fill_colors[self.source.index]
            elif fill:
                print self.source.index, self.line_list[self.source.index]
                if self.line_list[self.source.index] is not None:
                    conv = matplotlib.colors.ColorConverter()
                    edgecolor = linecolor
                    facecolor = conv.to_rgba(
                        color,
                        alpha=1 - (1 - self.alphas[self.source.index])**2)
                    self.proxies.append(
                        pylab.Rectangle((0, 0),
                                        1,
                                        1,
                                        facecolor=facecolor,
                                        edgecolor=edgecolor)
                    )  #,alpha=(1-(1-self.alphas[self.source.index])**2)))
                else:
                    self.proxies.append(
                        pylab.Rectangle(
                            (0, 0),
                            1,
                            1,
                            fc=color,
                            edgecolor=color,
                            alpha=(1 -
                                   (1 - self.alphas[self.source.index])**2)))
            else:
                self.proxies.append(
                    pylab.plot(
                        [], [],
                        color=color,
                        linestyle=linestyle,
                        linewidth=self.linewidths[self.source.index])[0])

        if self.plot_points is not None:
            point_markers = ['x', '+', '^']
            for p, m in zip(self.plot_points, point_markers):
                print p, m
                pylab.plot(p[0],
                           p[1],
                           m,
                           color='k',
                           markersize=10,
                           markerfacecolor='none')

        #Do the labels
        print self.proxies, self.labels
        if self.labels is not None:
            leg = pylab.legend(self.proxies, self.labels, loc="upper right")
            leg.get_frame().set_alpha(
                0)  # this will make the box totally transparent
            leg.get_frame().set_edgecolor(
                'white')  # this will make the edges of the
        pylab.xlabel(self.latex(name1))
        pylab.ylabel(self.latex(name2))
        pylab.tight_layout()
        if self.axis is not None:
            pylab.axis(self.axis)
        return filename