def pairplot(self, argin): """plot array of plots for all pairs of columns <query> [<options>] - continuous-continuous as scatter (optional KDE contour) - continuous-categorical as violinplot - categorical-categorical as heatmap Options: -f, --filename: the output filename. If not specified, tries to draw. -g, --generator: the generator name. Providing the generator name make help to plot more intelligently. -s, --shortnames: Use column short names to label facets? -m, --show-missing: Plot missing values in scatter plots as lines. -t, --no-tril: Plot the entire square matrix, not just lower triangle. --show-contour: Turn on contours. --colorby: The name of a column to use as a marker variable for color. Example: bayeslite> .show SELECT foo, baz, quux + glorb FROM mytable --filename myfile.png bayeslite> .show ESTIMATE foo, baz FROM mytable_cc -g mytable_cc """ parser = ArgumentParser(prog='.show') parser.add_argument('bql', type=str, nargs='+', help='BQL query') parser.add_argument('-f', '--filename', type=str, default=None, help='output filename') parser.add_argument('-g', '--generator', type=str, default=None, help='Query generator name') parser.add_argument('-s', '--shortnames', action='store_true', help='Use column short names?') parser.add_argument('--no-contour', action='store_true', help='Turn off countours (KDE).'), parser.add_argument('--show-contour', action='store_true', help='Turn on contours (KDE).') parser.add_argument('-m', '--show-missing', action='store_true', help='Plot missing values in scatterplot.') parser.add_argument('--show-full', action='store_true') parser.add_argument('--colorby', type=str, default=None, help='Name of column to use as a dummy variable.') try: args = parser.parse_args(shlex.split(argin)) except ArgparseError as e: self.stdout.write('%s' % (e.message,)) return bql = " ".join(args.bql) figure = bdbcontrib.pairplot(self._bdb, bql, generator_name=args.generator, show_contour=args.show_contour, colorby=args.colorby, show_missing=args.show_missing, show_full=args.show_full) if args.filename is None: plt.show() else: figure.savefig(args.filename) plt.close('all')
def pairplot(self, cols, plotfile=None, colorby=None, **kwargs): """Wrap bdbcontrib.plot_utils.pairplot to show the given columns. Specifies bdb, query with the given columns, and generator_name: bdbcontrib_pairplot """ if len(cols) < 1: raise ValueError('Pairplot at least one variable.') qcols = cols if colorby is None else set(cols + [colorby]) query_columns = '''"%s"''' % '''", "'''.join(qcols) with logged_query(query_string='pairplot cols=?', bindings=(query_columns,), name=self.session_capture_name): self.logger.plot(plotfile, bdbcontrib.pairplot(self.bdb, '''SELECT %s FROM %s''' % (query_columns, self.name), generator_name=self.generator_name, colorby=colorby, **kwargs))
value1 = str(table_tr[j][0]), value2 = str(table_tr[j][1]), value3 = str(table_tr[j][2])) header1.append(row) footer = str(open("html/footer_select.html").read()) header1.append(footer) final = ' '.join(header1) return final #pairplot liste = test.quick_describe_columns() gen_cols = [str(liste.iloc[0,1]),str(liste.iloc[1,1])] PP = bdbcontrib.pairplot(bdb, ''' SELECT {string1},{string2} FROM dfr;'''.format(string1='"' + gen_cols[0] + '"', string2='"' + gen_cols[1] + '"')); plt.savefig("images/PP_"+basename,bbox_extra_artists=(lgd,), bbox_inches='tight') #Missing values n = len(matt) def miss(): matt = np.array(bdbcontrib.describe_generator_columns(bdb, 'dfr_cc')) array = datareduce.columns.values header = [str(open("html/header_table.html").read())] for (j,k) in zip(range(0, (n/2)-1),range(n/2, n-1)): row = str(open("html/row_table.html").read()).format(colname1 = str(matt[j][1]), count1 = datar.count()[j],
def pairplot(self, argin): """plot array of plots for all pairs of columns <query> [<options>] - continuous-continuous as scatter (optional KDE contour) - continuous-categorical as violinplot - categorical-categorical as heatmap Options: -f, --filename: the output filename. If not specified, tries to draw. -g, --generator: the generator name. Providing the generator name make help to plot more intelligently. -s, --shortnames: Use column short names to label facets? -m, --show-missing: Plot missing values in scatter plots as lines. -t, --no-tril: Plot the entire square matrix, not just lower triangle. --show-contour: Turn on contours. --colorby: The name of a column to use as a marker variable for color. Example: bayeslite> .show SELECT foo, baz, quux + glorb FROM mytable --filename myfile.png bayeslite> .show ESTIMATE foo, baz FROM mytable_cc -g mytable_cc """ parser = ArgumentParser(prog='.show') parser.add_argument('bql', type=str, nargs='+', help='BQL query') parser.add_argument('-f', '--filename', type=str, default=None, help='output filename') parser.add_argument('-g', '--generator', type=str, default=None, help='Query generator name') parser.add_argument('-s', '--shortnames', action='store_true', help='Use column short names?') parser.add_argument('--no-contour', action='store_true', help='Turn off countours (KDE).'), parser.add_argument('--show-contour', action='store_true', help='Turn on contours (KDE).') parser.add_argument('-m', '--show-missing', action='store_true', help='Plot missing values in scatterplot.') parser.add_argument('--show-full', action='store_true') parser.add_argument('--colorby', type=str, default=None, help='Name of column to use as a dummy variable.') try: args = parser.parse_args(shlex.split(argin)) except ArgparseError as e: self.stdout.write('%s' % (e.message, )) return bql = " ".join(args.bql) figure = bdbcontrib.pairplot(self._bdb, bql, generator_name=args.generator, show_contour=args.show_contour, colorby=args.colorby, show_missing=args.show_missing, show_full=args.show_full) if args.filename is None: plt.show() else: figure.savefig(args.filename) plt.close('all')
value2=str(table_tr[j][1]), value3=str(table_tr[j][2])) header1.append(row) footer = str(open("html/footer_select.html").read()) header1.append(footer) final = ' '.join(header1) return final #pairplot liste = test.quick_describe_columns() gen_cols = [str(liste.iloc[0, 1]), str(liste.iloc[1, 1])] PP = bdbcontrib.pairplot( bdb, ''' SELECT {string1},{string2} FROM dfr;'''.format(string1='"' + gen_cols[0] + '"', string2='"' + gen_cols[1] + '"')) plt.savefig("images/PP_" + basename, bbox_extra_artists=(lgd, ), bbox_inches='tight') #Missing values n = len(matt) def miss(): matt = np.array(bdbcontrib.describe_generator_columns(bdb, 'dfr_cc')) array = datareduce.columns.values header = [str(open("html/header_table.html").read())] for (j, k) in zip(range(0, (n / 2) - 1), range(n / 2, n - 1)):