def main(): args = get_args(__file__) labels = [ 'N/A', 'Id. Física', 'Id. Historiográfica', 'Desconocido', 'Perdido' ] colornames = ['light grey', 'medium green', 'denim blue', 'pale red'] df = pd.DataFrame(read_table(args.table)) df['ident'] = df.apply(categorize, axis=1) data = df\ .drop_duplicates(['bid', 'lid'], keep='first')\ .pivot(index='bid', columns='lid', values='ident')\ .fillna(0) #colors = sns.color_palette('hls', len(data)) #colors = sns.color_palette('husl', len(data)) #colors = sns.light_palette('red', len(data)) colors = sns.xkcd_palette(colornames) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), 'Libros') legend(f, ax, labels, colors) plotting(plt, args)
def plot(args): df = pd.DataFrame(read_table(args.table)) configurer = configs[args.color_by] data, labels, colors = configurer(df, args.color_by) f, ax = plt.subplots() fig = sns.heatmap( data, ax=ax, #square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), ylabel='Posición') legend(f, ax, labels, colors) if args.annotated and args.color_by in ['bid', 'year']: df_by_bid = df.drop_duplicates('bid').set_index('bid') texts = [ fig.text( 15, bid, df.loc[bid, 'short'], fontsize=8, ) for bid, row in data.iterrows() ] plotting(plt, args)
def main(): args = get_args(__file__) df = pd.DataFrame(read_table(args.table)) def track(row): # Mark it as id, which will go in red return 1000 if row['bid'] == 25 else row['bid'] df['track'] = df.apply(track, axis=1) data = df.pivot(index='pos', columns='lid', values='track') colornames = ['light blue', 'bright red'] colors = sns.xkcd_palette(colornames) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), 'Posición') plotting(plt, args)
def main(): args = get_args(__file__) df = pd.DataFrame(read_table(args.table)) data = df.pivot(index='pos', columns='lid', values='bid') # colors = sns.color_palette('hls', len(data)) # colors = sns.color_palette('husl', len(data)) # colors = sns.light_palette('red', len(data)) colors = sns.light_palette('navy', len(data)) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), 'Posición') plotting(plt, args)
def main(): args = get_args(__file__) names = ['NA', 'LAT', 'ROM', 'FRAN'] labels = ['N/A', 'Latín', 'Romance', 'Francés'] colornames = ['light grey', 'pale red', 'medium green', 'denim blue'] df = pd.DataFrame(read_table(args.table)) data = categorical_by(df, 'lang', names) colors = sns.xkcd_palette(colornames) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), 'Libros') legend(f, ax, labels, colors) plotting(plt, args)
def main(): args = get_args(__file__) names = ['NA', 'REL', 'CRONIC', 'ANTI'] labels = ['N/A', 'Religioso', 'Crónicas y Leyes', 'Historia Antigua'] colornames = ['light grey', 'pale red', 'medium green', 'denim blue'] df = pd.DataFrame(read_table(args.table)) #df = pd.read_csv(args.table) data = categorical_by(df, 'topic', names) colors = sns.xkcd_palette(colornames) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(df.year.values), ylabel='Posición') legend(f, ax, labels, colors) plotting(plt, args)
def main(): args = get_args(__file__) df = pd.DataFrame(read_table(args.table)) sizes = len(range(int(df['height'].max()))) data = df.pivot(index='pos', columns='lid', values='height').fillna(0) #colors = sns.color_palette('cubehelix', sizes) #colors = sns.color_palette('hls', len(data)) #colors = sns.color_palette('husl', len(data)) #colors = sns.light_palette('red', sizes) #colors = sns.light_palette('navy', sizes) colors = sns.light_palette('green', sizes) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), 'Tamaño') plotting(plt, args)
def main(): args = get_args(__file__) df = pd.DataFrame(read_table(args.table)) data = df\ .drop_duplicates(['bid', 'lid'], keep='first')\ .pivot(index='bid', columns='lid', values='year')\ .fillna(False) #colors = sns.color_palette('hls', len(data)) #colors = sns.color_palette('husl', len(data)) colors = sns.light_palette('red', len(data)) f, ax = plt.subplots() sns.heatmap(data, ax=ax, square=True, linewidth=0.5, cmap=ListedColormap(colors), cbar=False) set_axis(ax, data, as_letters(set(df.year.values)), 'Libros') plotting(plt, args)