def _summary_table(labels, data, names=None, datafile=None, infofile=None): """ Summarize multiple parameters in a table. :returns: Table of summary statistics for particular parameters :rtype: string """ # Summarize all parameters by default if names is None: names = labels.values() # Make a string describing credible interval beta_percent = 100. * (1. - default("alpha")[1]) credible_name = "%.2g%% credible region" % beta_percent # Headings for a table headings = ["Name", "best-fit", "posterior mean", credible_name, "" ] param_table = pt(headings) param_table.align = "l" param_table.float_format = "4.2" # Make summary data and add it to table posterior = data[0] chi_sq = data[1] for key, name in labels.iteritems(): if name in names: param = data[key] param_table.add_row(_summary(name, param, posterior, chi_sq)) # Best-fit information and information about chain min_chi_sq = data[1].min() p_value = stats.p_value(data[1], default("dof")) bestfit_table = pt(header=False) bestfit_table.align = "l" bestfit_table.float_format = "4.2" bestfit_table.add_row(["File", datafile]) bestfit_table.add_row(["Info-file", infofile]) bestfit_table.add_row(["Minimum chi-squared", min_chi_sq]) bestfit_table.add_row(["p-value", p_value]) return bestfit_table.get_string() + "\n\n" + param_table.get_string()
def _cblimits(self, textbox): """ Callback function for setting bin limits. :param textbox: Box with this callback function :type textbox: """ # If no limits, return default if not textbox.get_text().strip(): self.bin_limits = default("bin_limits") return # Split text by commas etc self.bin_limits = re.split(r"\s*[,;]\s*", textbox.get_text()) # Convert to floats self.bin_limits = [float(i) for i in self.bin_limits if i] # Permit only two floats, if it is a one-dimensional plot one_dim_plot = "One-dimensional" in self.typebox.get_active_text() if len(self.bin_limits) == 2 and not one_dim_plot: raise RuntimeError("Specify four floats for bin limits in 2D plot") elif len(self.bin_limits) != 2 and one_dim_plot: raise RuntimeError("Specify two floats for bin limits in 1D plot") elif len(self.bin_limits) == 4 and not one_dim_plot: # Convert to two-tuple format try: self.bin_limits = [[self.bin_limits[0], self.bin_limits[1]], [self.bin_limits[2], self.bin_limits[3]]] except: raise IndexError( "Specify four floats for bin limits in 2D plot") else: raise RuntimeError("Specify four floats for bin limits in 2D plot")
def _cblimits(self, textbox): """ Callback function for setting bin limits. :param textbox: Box with this callback function :type textbox: """ # If no limits, return default if not textbox.get_text().strip(): self.bin_limits = default("bin_limits") return # Split text by commas etc self.bin_limits = re.split(r"\s*[,;]\s*", textbox.get_text()) # Convert to floats self.bin_limits = [float(i) for i in self.bin_limits if i] # Permit only two floats, if it is a one-dimensional plot one_dim_plot = "One-dimensional" in self.typebox.get_active_text() if len(self.bin_limits) == 2 and not one_dim_plot: raise RuntimeError("Specify four floats for bin limits in 2D plot") elif len(self.bin_limits) != 2 and one_dim_plot: raise RuntimeError("Specify two floats for bin limits in 1D plot") elif len(self.plot_limits) == 4 and not one_dim_plot: # Convert to two-tuple format try: self.bin_limits = [[self.bin_limits[0], self.bin_limits[1]], [ self.bin_limits[2], self.bin_limits[3]]] except: raise IndexError("Specify four floats for bin limits in 2D plot") else: raise RuntimeError("Specify four floats for bin limits in 2D plot")
def _summary(name, param, posterior, chi_sq): """ Find summary statistics for a single parameter. :param name: Name of parameter :type name: string :param param: Data column of parameter :type param: :param posterior: :type posterior: :param chi_sq: :type chi_sq: :returns: List of summary statistics for a particular parameter :rtype: list """ # Best-fit point bestfit = stats.best_fit(chi_sq, param) # Posterior mean post_mean = stats.posterior_mean(posterior, param) # Credible regions pdf_data = one_dim.posterior_pdf(param, posterior, nbins=default("nbins"), bin_limits=default("bin_limits") ) lower_credible_region = one_dim.credible_region(pdf_data.pdf, pdf_data.bin_centers, alpha=default("alpha")[1], region="lower") upper_credible_region = one_dim.credible_region(pdf_data.pdf, pdf_data.bin_centers, alpha=default("alpha")[1], region="upper") summary = [name, bestfit, post_mean, lower_credible_region, upper_credible_region ] return summary
def _calimits(self, textbox): """ Callback function for setting axes limits. :param textbox: Box with this callback function :type textbox: """ # If no limits, return default if not textbox.get_text().strip(): self.plot_limits = default("plot_limits") return # Split text by commas etc self.plot_limits = re.split(r"\s*[,;]\s*", textbox.get_text()) # Convert to floats self.plot_limits = [float(i) for i in self.plot_limits if i] # Permit only two floats, if it is a one-dimensional plot if len(self.plot_limits) == 2 and "One-dimensional" in self.typebox.get_active_text(): self.plot_limits += [None, None] elif len(self.plot_limits) != 4: raise RuntimeError("Must specify four floats for axes limits")
def _calimits(self, textbox): """ Callback function for setting axes limits. :param textbox: Box with this callback function :type textbox: """ # If no limits, return default if not textbox.get_text().strip(): self.plot_limits = default("plot_limits") return # Split text by commas etc self.plot_limits = re.split(r"\s*[,;]\s*", textbox.get_text()) # Convert to floats self.plot_limits = [float(i) for i in self.plot_limits if i] # Permit only two floats, if it is a one-dimensional plot if len(self.plot_limits ) == 2 and "One-dimensional" in self.typebox.get_active_text(): self.plot_limits += [None, None] elif len(self.plot_limits) != 4: raise RuntimeError("Must specify four floats for axes limits")
def _pmakeplot(self, button): """ Callback function for pressing make plot. Main action is that it calls a ploting function that returns a figure object that is attached to our window. :param button: Button with this callback function :type button: """ # Gather up all of the plot options and put them in # a plot_options tuple args = {"xindex": self.xindex, "yindex": self.yindex, "zindex": self.zindex, "logx": self.logx.get_active(), "logy": self.logy.get_active(), "logz": self.logz.get_active(), "plot_limits": self.plot_limits, "bin_limits": self.bin_limits, "nbins": self.bins.get_value_as_int(), "xticks": default("xticks"), "yticks": default("yticks"), "tau": default("tau"), "alpha": default("alpha"), "xlabel": self.labels[self.xindex], "ylabel": self.labels[self.yindex], "zlabel": self.labels[self.zindex], "plot_title": self.plottitle.get_text(), "leg_title": self.legtitle.get_text(), "leg_position": self.legpos.get_active_text(), "show_best_fit": self.show_best_fit.get_active(), "show_posterior_mean": self.show_posterior_mean.get_active(), "show_conf_intervals": self.show_conf_intervals.get_active(), "show_credible_regions": self.show_credible_regions.get_active(), "show_posterior_pdf": self.show_posterior_pdf.get_active(), "show_prof_like": self.show_prof_like.get_active() } self.options = plot_options(**args) # Fetch the class for the selected plot type plot_class = self.plots[self.typebox.get_active_text()] # Instantiate the plot and get the figure self.fig = plot_class(self.data, self.options).figure() # Also store a handle to the plot class instance. # This is used for pickling - which needs to # re-create the figure to work correctly. self.plot = plot_class(self.data, self.options) # Put figure in plot box canvas = FigureCanvas(self.fig.figure) # A gtk.DrawingArea self.gridbox.attach(canvas, 2, 5, 0, 15) # Button to save the plot save_button = gtk.Button('Save plot.') save_button.connect("clicked", self._psave) self.gridbox.attach(save_button, 2, 5, 16, 17) # Attach the check boxes to specify what is saved self.gridbox.attach(self._align_center(self.save_image), 2, 3, 15, 16) self.gridbox.attach(self._align_center(self.save_summary), 3, 4, 15, 16) self.gridbox.attach(self._align_center(self.save_pickle), 4, 5, 15, 16) # Show new buttons etc self.window.show_all()
def __init__(self, data_file, info_file, xindex=2, yindex=3, zindex=4, default_plot_type=0 ): self.data_file = data_file self.info_file = info_file self.xindex = xindex self.yindex = yindex self.zindex = zindex self.plot_limits = default("plot_limits") self.bin_limits = default("bin_limits") self.fig = None self.plot = None self.options = None # Load data from files self.labels, self.data = data_loader.load(info_file, data_file) # Enumerate available plot types and keep an ordered # dict mapping descriptions to classes. # Using an ordered dict means the order in which classes # are listed in plot_types will be preserved in the GUI. self.plots = OrderedDict() for plot_class in plots.plot_types: self.plots[plot_class.description] = plot_class ####################################################################### # Combo-box for various plot types typetitle = gtk.Button("Plot type:") self.typebox = gtk.combo_box_new_text() for description in self.plots.keys(): self.typebox.append_text(description) self.typebox.set_active(default_plot_type) # Set to default plot type ####################################################################### # Combo box for selecting x-axis variable xtitle = gtk.Button("x-axis variable:") self.xbox = gtk.combo_box_new_text() for label in self.labels.itervalues(): self.xbox.append_text(label) self.xbox.set_wrap_width(5) self.xbox.connect('changed', self._cx) self.xtext = gtk.Entry() self.xtext.set_text(self.labels[self.xindex]) self.xtext.connect("changed", self._cxtext) self.xbox.set_active(self.xindex) ####################################################################### # Combo box for selecting y-axis variable ytitle = gtk.Button("y-axis variable:") self.ybox = gtk.combo_box_new_text() for label in self.labels.itervalues(): self.ybox.append_text(label) self.ybox.set_wrap_width(5) self.ybox.connect('changed', self._cy) self.ytext = gtk.Entry() self.ytext.set_text(self.labels[self.yindex]) self.ytext.connect("changed", self._cytext) self.ybox.set_active(self.yindex) ####################################################################### # Combo box for selecting z-axis variable ztitle = gtk.Button("z-axis variable:") self.zbox = gtk.combo_box_new_text() for label in self.labels.itervalues(): self.zbox.append_text(label) self.zbox.set_wrap_width(5) self.zbox.connect('changed', self._cz) self.ztext = gtk.Entry() self.ztext.set_text(self.labels[self.zindex]) self.ztext.connect("changed", self._cztext) self.zbox.set_active(self.zindex) ####################################################################### # Check buttons for log Scaling self.logx = gtk.CheckButton('Log x-data.') self.logy = gtk.CheckButton('Log y-data.') self.logz = gtk.CheckButton('Log z-data.') ####################################################################### # Text boxt for plot title tplottitle = gtk.Button("Plot title:") self.plottitle = gtk.Entry() self.plottitle.set_text(default("plot_title")) ####################################################################### # Legend properties # Text box for legend title tlegtitle = gtk.Button("Legend title:") self.legtitle = gtk.Entry() self.legtitle.set_text("") # Combo box for legend position tlegpos = gtk.Button("Legend position:") self.legpos = gtk.combo_box_new_text() for loc in ["best", "upper right", "lower left", "lower right", "right", "center left", "center right", "lower center", "upper center", "center", "no legend"]: self.legpos.append_text(loc) self.legpos.set_active(0) # Default is first in above list - "best" ####################################################################### # Spin button for number of bins per dimension tbins = gtk.Button("Bins per dimension:") self.bins = gtk.SpinButton() self.bins.set_increments(10, 10) self.bins.set_range(5, 10000) self.bins.set_value(default("nbins")) ####################################################################### # Axes limits alimits = gtk.Button("Comma separated plot limits\n" "x_min, x_max, y_min, y_max:") self.alimits = gtk.Entry() self.alimits.connect("changed", self._calimits) self.alimits.append_text("") ####################################################################### # Bin limits blimits = gtk.Button("Comma separated bin limits\n" "x_min, x_max, y_min, y_max:") self.blimits = gtk.Entry() self.blimits.connect("changed", self._cblimits) self.blimits.append_text("") ####################################################################### # Check buttons for optional plot elements self.show_best_fit = gtk.CheckButton("Best-fit") self.show_posterior_mean = gtk.CheckButton("Posterior mean") self.show_credible_regions = gtk.CheckButton("Credible regions") self.show_conf_intervals = gtk.CheckButton("Confidence intervals") self.show_posterior_pdf = gtk.CheckButton("Posterior PDF") self.show_prof_like = gtk.CheckButton("Profile Likelihood") self.show_best_fit.set_active(True) self.show_posterior_mean.set_active(True) self.show_credible_regions.set_active(True) self.show_conf_intervals.set_active(True) self.show_posterior_pdf.set_active(True) self.show_prof_like.set_active(True) ####################################################################### # Make plot button makeplot = gtk.Button('Make plot.') makeplot.connect("clicked", self._pmakeplot) ####################################################################### # Check boxes to control what is saved (note we only attach them to the # window after showing a plot) self.save_image = gtk.CheckButton('Save image') self.save_image.set_active(True) self.save_summary = gtk.CheckButton('Save statistics in plot') self.save_summary.set_active(True) self.save_pickle = gtk.CheckButton('Save pickle of plot') self.save_pickle.set_active(True) ####################################################################### # Layout - GTK Table self.gridbox = gtk.Table(17, 5, False) self.gridbox.attach(typetitle, 0, 1, 0, 1, xoptions=gtk.FILL) self.gridbox.attach(self.typebox, 1, 2, 0, 1, xoptions=gtk.FILL) self.gridbox.attach(xtitle, 0, 1, 1, 2, xoptions=gtk.FILL) self.gridbox.attach(self.xbox, 1, 2, 1, 2, xoptions=gtk.FILL) self.gridbox.attach(self.xtext, 1, 2, 2, 3, xoptions=gtk.FILL) self.gridbox.attach(ytitle, 0, 1, 3, 4, xoptions=gtk.FILL) self.gridbox.attach(self.ybox, 1, 2, 3, 4, xoptions=gtk.FILL) self.gridbox.attach(self.ytext, 1, 2, 4, 5, xoptions=gtk.FILL) self.gridbox.attach(ztitle, 0, 1, 5, 6, xoptions=gtk.FILL) self.gridbox.attach(self.zbox, 1, 2, 5, 6, xoptions=gtk.FILL) self.gridbox.attach(self.ztext, 1, 2, 6, 7, xoptions=gtk.FILL) self.gridbox.attach(self.logx, 0, 1, 2, 3, xoptions=gtk.FILL) self.gridbox.attach(self.logy, 0, 1, 4, 5, xoptions=gtk.FILL) self.gridbox.attach(self.logz, 0, 1, 6, 7, xoptions=gtk.FILL) self.gridbox.attach(tplottitle, 0, 1, 9, 10, xoptions=gtk.FILL) self.gridbox.attach(self.plottitle, 1, 2, 9, 10, xoptions=gtk.FILL) self.gridbox.attach(tlegtitle, 0, 1, 10, 11, xoptions=gtk.FILL) self.gridbox.attach(self.legtitle, 1, 2, 10, 11, xoptions=gtk.FILL) self.gridbox.attach(tlegpos, 0, 1, 11, 12, xoptions=gtk.FILL) self.gridbox.attach(self.legpos, 1, 2, 11, 12, xoptions=gtk.FILL) self.gridbox.attach(tbins, 0, 1, 12, 13, xoptions=gtk.FILL) self.gridbox.attach(self.bins, 1, 2, 12, 13, xoptions=gtk.FILL) self.gridbox.attach(alimits, 0, 1, 13, 14, xoptions=gtk.FILL) self.gridbox.attach(self.alimits, 1, 2, 13, 14, xoptions=gtk.FILL) self.gridbox.attach(blimits, 0, 1, 14, 15, xoptions=gtk.FILL) self.gridbox.attach(self.blimits, 1, 2, 14, 15, xoptions=gtk.FILL) point_plot_container = gtk.VBox() point_plot_box_upper = gtk.HBox(homogeneous=True) point_plot_box_lower = gtk.HBox(homogeneous=True) for check_box in [self.show_conf_intervals, self.show_credible_regions, self.show_best_fit]: point_plot_box_upper.pack_start_defaults(check_box) for check_box in [self.show_posterior_mean, self.show_posterior_pdf, self.show_prof_like]: point_plot_box_lower.pack_start_defaults(check_box) point_plot_container.pack_start_defaults(point_plot_box_upper) point_plot_container.pack_start_defaults(point_plot_box_lower) self.gridbox.attach(point_plot_container, 0, 2, 15, 16, xoptions=gtk.FILL) self.gridbox.attach(makeplot, 0, 2, 16, 17, xoptions=gtk.FILL) ####################################################################### # Make main GUI window self.window = gtk.Window() self.window.maximize() self.window.set_title("SuperPlot") # Quit if cross is pressed self.window.connect('destroy', lambda w: gtk.main_quit()) # Add the table to the window and show self.window.add(self.gridbox) self.gridbox.show() self.window.show_all() return
def _pmakeplot(self, button): """ Callback function for pressing make plot. Main action is that it calls a ploting function that returns a figure object that is attached to our window. :param button: Button with this callback function :type button: """ # Gather up all of the plot options and put them in # a plot_options tuple args = { "xindex": self.xindex, "yindex": self.yindex, "zindex": self.zindex, "logx": self.logx.get_active(), "logy": self.logy.get_active(), "logz": self.logz.get_active(), "plot_limits": self.plot_limits, "bin_limits": self.bin_limits, "nbins": self.bins.get_value_as_int(), "xticks": default("xticks"), "yticks": default("yticks"), "tau": default("tau"), "alpha": default("alpha"), "xlabel": self.labels[self.xindex], "ylabel": self.labels[self.yindex], "zlabel": self.labels[self.zindex], "plot_title": self.plottitle.get_text(), "title_position": default("title_position"), "leg_title": self.legtitle.get_text(), "leg_position": self.legpos.get_active_text(), "show_best_fit": self.show_best_fit.get_active(), "show_posterior_mean": self.show_posterior_mean.get_active(), "show_posterior_median": self.show_posterior_median.get_active(), "show_posterior_mode": self.show_posterior_mode.get_active(), "show_conf_intervals": self.show_conf_intervals.get_active(), "show_credible_regions": self.show_credible_regions.get_active(), "show_posterior_pdf": self.show_posterior_pdf.get_active(), "show_prof_like": self.show_prof_like.get_active(), "kde_pdf": self.kde_pdf.get_active(), "bw_method": default("bw_method") } self.options = plot_options(**args) # Fetch the class for the selected plot type plot_class = self.plots[self.typebox.get_active_text()] # Instantiate the plot and get the figure self.fig = plot_class(self.data, self.options).figure() # Also store a handle to the plot class instance. # This is used for pickling - which needs to # re-create the figure to work correctly. self.plot = plot_class(self.data, self.options) # Put figure in plot box canvas = FigureCanvas(self.fig.figure) # A gtk.DrawingArea self.gridbox.attach(canvas, 2, 5, 0, 15) # Button to save the plot save_button = gtk.Button('Save plot.') save_button.connect("clicked", self._psave) self.gridbox.attach(save_button, 2, 5, 16, 17) # Attach the check boxes to specify what is saved self.gridbox.attach(self._align_center(self.save_image), 2, 3, 15, 16) self.gridbox.attach(self._align_center(self.save_summary), 3, 4, 15, 16) self.gridbox.attach(self._align_center(self.save_pickle), 4, 5, 15, 16) # Show new buttons etc self.window.show_all()
def __init__(self, data_file, info_file, default_plot_type=0): self.data_file = data_file self.info_file = info_file self.plot_limits = default("plot_limits") self.bin_limits = default("bin_limits") self.fig = None self.plot = None self.options = None # Load data from files self.labels, self.data = data_loader.load(info_file, data_file) # We need at least three columns - posterior, chisq & a data column data_columns = self.data.shape[0] assert data_columns >= 3 # Set x, y & z indices to first three data columns after the # posterior and chisq. If there are less than three such columns # assign to the rightmost available column. self.xindex = 2 self.yindex = min(3, data_columns - 1) self.zindex = min(4, data_columns - 1) # Enumerate available plot types and keep an ordered # dict mapping descriptions to classes. # Using an ordered dict means the order in which classes # are listed in plot_types will be preserved in the GUI. self.plots = OrderedDict() for plot_class in plots.plot_types: self.plots[plot_class.description] = plot_class ####################################################################### # Combo-box for various plot types typetitle = gtk.Button("Plot type:") self.typebox = gtk.combo_box_new_text() for description in self.plots.keys(): self.typebox.append_text(description) self.typebox.set_active(default_plot_type) # Set to default plot type ####################################################################### # Combo box for selecting x-axis variable xtitle = gtk.Button("x-axis variable:") self.xbox = gtk.combo_box_new_text() for label in self.labels.itervalues(): self.xbox.append_text(label) self.xbox.set_wrap_width(5) self.xbox.connect('changed', self._cx) self.xtext = gtk.Entry() self.xtext.set_text(self.labels[self.xindex]) self.xtext.connect("changed", self._cxtext) self.xbox.set_active(self.xindex) ####################################################################### # Combo box for selecting y-axis variable ytitle = gtk.Button("y-axis variable:") self.ybox = gtk.combo_box_new_text() for label in self.labels.itervalues(): self.ybox.append_text(label) self.ybox.set_wrap_width(5) self.ybox.connect('changed', self._cy) self.ytext = gtk.Entry() self.ytext.set_text(self.labels[self.yindex]) self.ytext.connect("changed", self._cytext) self.ybox.set_active(self.yindex) ####################################################################### # Combo box for selecting z-axis variable ztitle = gtk.Button("z-axis variable:") self.zbox = gtk.combo_box_new_text() for label in self.labels.itervalues(): self.zbox.append_text(label) self.zbox.set_wrap_width(5) self.zbox.connect('changed', self._cz) self.ztext = gtk.Entry() self.ztext.set_text(self.labels[self.zindex]) self.ztext.connect("changed", self._cztext) self.zbox.set_active(self.zindex) ####################################################################### # Check buttons for log Scaling self.logx = gtk.CheckButton('Log x-data.') self.logy = gtk.CheckButton('Log y-data.') self.logz = gtk.CheckButton('Log z-data.') ####################################################################### # Text boxt for plot title tplottitle = gtk.Button("Plot title:") self.plottitle = gtk.Entry() self.plottitle.set_text(default("plot_title")) ####################################################################### # Legend properties # Text box for legend title tlegtitle = gtk.Button("Legend title:") self.legtitle = gtk.Entry() self.legtitle.set_text("") # Combo box for legend position tlegpos = gtk.Button("Legend position:") self.legpos = gtk.combo_box_new_text() for loc in [ "best", "upper right", "lower left", "lower right", "right", "center left", "center right", "lower center", "upper center", "center", "no legend" ]: self.legpos.append_text(loc) self.legpos.set_active(0) # Default is first in above list - "best" ####################################################################### # Spin button for number of bins per dimension tbins = gtk.Button("Bins per dimension:") self.bins = gtk.SpinButton() self.bins.set_increments(10, 10) self.bins.set_range(5, 10000) self.bins.set_value(default("nbins")) ####################################################################### # Axes limits alimits = gtk.Button("Comma separated plot limits\n" "x_min, x_max, y_min, y_max:") self.alimits = gtk.Entry() self.alimits.connect("changed", self._calimits) self.alimits.append_text("") ####################################################################### # Bin limits blimits = gtk.Button("Comma separated bin limits\n" "x_min, x_max, y_min, y_max:") self.blimits = gtk.Entry() self.blimits.connect("changed", self._cblimits) self.blimits.append_text("") ####################################################################### # Check buttons for optional plot elements self.show_best_fit = gtk.CheckButton("Best-fit") self.show_posterior_mean = gtk.CheckButton("Posterior mean") self.show_posterior_median = gtk.CheckButton("Posterior median") self.show_posterior_mode = gtk.CheckButton("Posterior mode") self.show_credible_regions = gtk.CheckButton("Credible regions") self.show_conf_intervals = gtk.CheckButton("Confidence intervals") self.show_posterior_pdf = gtk.CheckButton("Posterior PDF") self.show_prof_like = gtk.CheckButton("Profile Likelihood") self.kde_pdf = gtk.CheckButton("KDE smoothing") self.show_best_fit.set_active(True) self.show_posterior_mean.set_active(True) self.show_posterior_median.set_active(True) self.show_posterior_mode.set_active(True) self.show_credible_regions.set_active(True) self.show_conf_intervals.set_active(True) self.show_posterior_pdf.set_active(True) self.show_prof_like.set_active(True) self.kde_pdf.set_active(False) ####################################################################### # Make plot button makeplot = gtk.Button('Make plot.') makeplot.connect("clicked", self._pmakeplot) ####################################################################### # Check boxes to control what is saved (note we only attach them to the # window after showing a plot) self.save_image = gtk.CheckButton('Save image') self.save_image.set_active(True) self.save_summary = gtk.CheckButton('Save statistics in plot') self.save_summary.set_active(True) self.save_pickle = gtk.CheckButton('Save pickle of plot') self.save_pickle.set_active(True) ####################################################################### # Layout - GTK Table self.gridbox = gtk.Table(17, 5, False) self.gridbox.attach(typetitle, 0, 1, 0, 1, xoptions=gtk.FILL) self.gridbox.attach(self.typebox, 1, 2, 0, 1, xoptions=gtk.FILL) self.gridbox.attach(xtitle, 0, 1, 1, 2, xoptions=gtk.FILL) self.gridbox.attach(self.xbox, 1, 2, 1, 2, xoptions=gtk.FILL) self.gridbox.attach(self.xtext, 1, 2, 2, 3, xoptions=gtk.FILL) self.gridbox.attach(ytitle, 0, 1, 3, 4, xoptions=gtk.FILL) self.gridbox.attach(self.ybox, 1, 2, 3, 4, xoptions=gtk.FILL) self.gridbox.attach(self.ytext, 1, 2, 4, 5, xoptions=gtk.FILL) self.gridbox.attach(ztitle, 0, 1, 5, 6, xoptions=gtk.FILL) self.gridbox.attach(self.zbox, 1, 2, 5, 6, xoptions=gtk.FILL) self.gridbox.attach(self.ztext, 1, 2, 6, 7, xoptions=gtk.FILL) self.gridbox.attach(self.logx, 0, 1, 2, 3, xoptions=gtk.FILL) self.gridbox.attach(self.logy, 0, 1, 4, 5, xoptions=gtk.FILL) self.gridbox.attach(self.logz, 0, 1, 6, 7, xoptions=gtk.FILL) self.gridbox.attach(tplottitle, 0, 1, 9, 10, xoptions=gtk.FILL) self.gridbox.attach(self.plottitle, 1, 2, 9, 10, xoptions=gtk.FILL) self.gridbox.attach(tlegtitle, 0, 1, 10, 11, xoptions=gtk.FILL) self.gridbox.attach(self.legtitle, 1, 2, 10, 11, xoptions=gtk.FILL) self.gridbox.attach(tlegpos, 0, 1, 11, 12, xoptions=gtk.FILL) self.gridbox.attach(self.legpos, 1, 2, 11, 12, xoptions=gtk.FILL) self.gridbox.attach(tbins, 0, 1, 12, 13, xoptions=gtk.FILL) self.gridbox.attach(self.bins, 1, 2, 12, 13, xoptions=gtk.FILL) self.gridbox.attach(alimits, 0, 1, 13, 14, xoptions=gtk.FILL) self.gridbox.attach(self.alimits, 1, 2, 13, 14, xoptions=gtk.FILL) self.gridbox.attach(blimits, 0, 1, 14, 15, xoptions=gtk.FILL) self.gridbox.attach(self.blimits, 1, 2, 14, 15, xoptions=gtk.FILL) self.gridbox.attach(makeplot, 0, 2, 16, 17, xoptions=gtk.FILL) ####################################################################### # Sub table to hold check boxes for toggling optional plot elements point_plot_container = gtk.Table(3, 3, True) point_plot_container.attach(self.show_conf_intervals, 0, 1, 0, 1) point_plot_container.attach(self.show_credible_regions, 0, 1, 1, 2) point_plot_container.attach(self.show_best_fit, 0, 1, 2, 3) point_plot_container.attach(self.show_posterior_mean, 1, 2, 0, 1) point_plot_container.attach(self.show_posterior_median, 1, 2, 1, 2) point_plot_container.attach(self.show_posterior_mode, 1, 2, 2, 3) point_plot_container.attach(self.show_posterior_pdf, 2, 3, 0, 1) point_plot_container.attach(self.show_prof_like, 2, 3, 1, 2) point_plot_container.attach(self.kde_pdf, 2, 3, 2, 3) self.gridbox.attach(point_plot_container, 0, 2, 15, 16, xoptions=gtk.FILL) ####################################################################### # Make main GUI window self.window = gtk.Window() self.window.maximize() self.window.set_title("SuperPlot") # Quit if cross is pressed self.window.connect('destroy', lambda w: gtk.main_quit()) # Add the table to the window and show self.window.add(self.gridbox) self.gridbox.show() self.window.show_all() return