diff --git a/docs/make_viz.py b/docs/make_viz.py index 05d0d01..1e38e9f 100644 --- a/docs/make_viz.py +++ b/docs/make_viz.py @@ -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') @@ -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') @@ -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")