def plot_tags_by_place(frame, stacked, outname=None): """ """ # Get colors colors = get_colors(frame.columns, PALETTE_NAME) # Draw initial plot frame.plot( kind='barh', stacked=stacked, color=colors, ) ax = plt.gca() # Hack: Remove horizontal line at y=0 inserted by pandas ax.lines.pop() # Adjust axes ax.invert_yaxis() ax.set_xlabel('Proportion') # Draw legend handles, labels = ax.get_legend_handles_labels() lgd = ax.legend( handles, labels, loc='upper left', bbox_to_anchor=(1, 1) ) lgd.get_frame().set_facecolor('none') # Save figure if outname: plt.savefig(outname + '.pdf', bbox_inches='tight')
def plot_tags_by_place(frame, stacked, outname=None): """ """ # Get colors colors = get_colors(frame.columns, PALETTE_NAME) # Draw initial plot frame.plot( kind='barh', stacked=stacked, color=colors, ) ax = plt.gca() # Hack: Remove horizontal line at y=0 inserted by pandas ax.lines.pop() # Adjust axes ax.invert_yaxis() ax.set_xlabel('Proportion') # Draw legend handles, labels = ax.get_legend_handles_labels() lgd = ax.legend(handles, labels, loc='upper left', bbox_to_anchor=(1, 1)) lgd.get_frame().set_facecolor('none') # Save figure if outname: plt.savefig(outname + '.pdf', bbox_inches='tight')
def test_reserved(self): colors = utils.get_colors(['foo', 'other', 'bar', 'baz'], 'husl') sns_colors = sns.utils.color_palette('husl', n_colors=3) sns_colors.insert(1, utils.reserved_labels['other']) assert_equal( colors, sns_colors )
def test_reserved(self): colors = utils.get_colors(['foo', 'other', 'bar', 'baz'], 'husl') sns_colors = sns.color_palette('husl', n_colors=3) sns_colors.insert(1, utils.reserved_labels['other']) assert_equal(colors, sns_colors)
def test_no_reserved(self): assert_equal(utils.get_colors(['foo', 'bar', 'baz'], 'husl'), sns.color_palette('husl', n_colors=3))
def test_no_reserved(self): assert_equal( utils.get_colors(['foo', 'bar', 'baz'], 'husl'), sns.utils.color_palette('husl', n_colors=3) )
pattern.tag_groups['pkg'].labels ) frame = pd.DataFrame( data, index=top_places, columns=pattern.tag_groups['pkg'].labels, ) min_count = min_prop * frame.sum().sum() sum0 = frame.sum() plot_frame = frame.ix[:, sum0 >= min_count] plot_frame['other'] = frame.ix[:, sum0 < min_count].sum(axis=1) colors = get_colors(plot_frame.columns, PALETTE_NAME) plot_frame = plot_frame.div( 1.0 * plot_frame.sum(axis=1), axis=0, ) plot_frame.plot( kind='barh', stacked=True, color=colors, ) ax = plt.gca() # Hack: Remove horizontal line at y=0 inserted by pandas ax.lines.pop()