Skip to content

Commit

Permalink
Sorting and colors on plots
Browse files Browse the repository at this point in the history
  • Loading branch information
caufieldjh committed Sep 16, 2024
1 parent 301cc12 commit 8b63859
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions docs/make_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
# https://plotly.com/python/pie-charts/#pie-charts-in-subplots

# Node counts across all ontologies, unmerged
nodeontos = ontos.loc[ontos["nodecount"] < 150000, "id"] = "All other ontologies"
# Sort the DataFrame by nodecount in descending order and select the top 10
top_ontos = ontos.nlargest(10, 'nodecount')

fig1 = px.bar(
ontos,
top_ontos,
x="id",
y="nodecount",
title="Nodes in KG-Bioportal",
title="Top 10 Ontologies by Node Count in KG-Bioportal",
text="nodecount"
)
fig1.update_traces(texttemplate='%{text:.2s}', textposition='outside')
Expand All @@ -28,17 +30,21 @@
plot_bgcolor="rgba(0, 0, 0, 0)",
paper_bgcolor="rgba(0, 0, 0, 0)",
xaxis_title="Ontology ID",
yaxis_title="Node Count"
yaxis_title="Node Count",
xaxis=dict(categoryorder='total descending')
)
fig1.update_traces(marker=dict(color=px.colors.qualitative.Plotly))
fig1.write_html("_includes/fig1.html", include_plotlyjs="cdn")

# Edge counts across all ontologies, unmerged
ontos.loc[ontos["edgecount"] < 150000, "id"] = "All other ontologies"
# Sort the DataFrame by nodecount in descending order and select the top 10
top_ontos = ontos.nlargest(10, 'edgecount')

fig2 = px.bar(
ontos,
top_ontos,
x="id",
y="edgecount",
title="Edges in KG-Bioportal",
title="Top 10 Ontologies by Edge Count in KG-Bioportal",
text="edgecount"
)
fig2.update_traces(texttemplate='%{text:.2s}', textposition='outside')
Expand All @@ -48,6 +54,8 @@
plot_bgcolor="rgba(0, 0, 0, 0)",
paper_bgcolor="rgba(0, 0, 0, 0)",
xaxis_title="Ontology ID",
yaxis_title="Edge Count"
yaxis_title="Edge Count",
xaxis=dict(categoryorder='total descending')
)
fig2.update_traces(marker=dict(color=px.colors.qualitative.Plotly))
fig2.write_html("_includes/fig2.html", include_plotlyjs="cdn")

0 comments on commit 8b63859

Please sign in to comment.