generated from sourmash-bio/sourmash_plugin_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
ref #48
tax_df = pd.read_csv('examples/tax/test.tax-mg.summarized.csv')
tax_df2 = tax_df[tax_df['rank'] == 'species']
tax_df2['name'] = tax_df2['lineage'].apply(lambda x: x.split(';')[-1])
fractions = list(tax_df2['fraction'].tolist())
names = list(tax_df2['name'].tolist())
# compute circle positions
circles = circlify.circlify(
fractions,
show_enclosure=False,
target_enclosure=circlify.Circle(x=0, y=0, r=1)
)
# reverse the order of the circles to match the order of data
circles = circles[::-1]
# Create just a figure and only one subplot
fig, ax = plt.subplots(figsize=(10, 10))
# Title
#ax.set_title('Basic circular packing')
# Remove axes
ax.axis('off')
# Find axis boundaries
lim = max(
max(
abs(circle.x) + circle.r,
abs(circle.y) + circle.r,
)
for circle in circles
)
plt.xlim(-lim, lim)
plt.ylim(-lim, lim)
# list of labels
labels = names[::-1]
# print circles
for circle, label in zip(circles, labels):
x, y, r = circle
ax.add_patch(plt.Circle((x, y), r, alpha=0.2, linewidth=2))
plt.annotate(
label,
(x, y),
va='center',
ha='center'
)
plt.savefig('/tmp/circles1.png')
produces:

Metadata
Metadata
Assignees
Labels
No labels