Skip to content

Commit

Permalink
chore: formatting and polish
Browse files Browse the repository at this point in the history
  • Loading branch information
zieka committed Nov 30, 2023
1 parent 5234f14 commit 9125462
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"fig.update_layout(\n",
" title_text=\"Recipes that made changes\",\n",
" font_size=10,\n",
" height=max(len(all_nodes)*15, 400),\n",
" height=max(len(all_nodes) * 15, 400),\n",
")\n",
"\n",
"fig.show()"
Expand Down
79 changes: 44 additions & 35 deletions moderne_visualizations_misc/dependency_usage_violin.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"metadata": {},
"outputs": [],
"source": [
"df = df[['artifactId', 'version', 'depth']]"
"df = df[[\"artifactId\", \"version\", \"depth\"]]"
]
},
{
Expand All @@ -27,16 +27,20 @@
"outputs": [],
"source": [
"from code_data_science.versions import index as index_versions\n",
"\n",
"vmap = index_versions(df.version)\n",
"df['nVersion'] = list(map(lambda v: vmap[v], df.version))\n",
"df[\"nVersion\"] = list(map(lambda v: vmap[v], df.version))\n",
"\n",
"\n",
"def index_ga(groupartifacts):\n",
" sorted_ga = sorted(list(set(groupartifacts)))\n",
" return { ga : sorted_ga.index(ga) for ga in sorted_ga }\n",
" return {ga: sorted_ga.index(ga) for ga in sorted_ga}\n",
"\n",
"\n",
"gmap = index_ga(df.artifactId)\n",
"df['nArtifactId'] = list(map(lambda g: gmap[g], df.artifactId))\n",
"df[\"nArtifactId\"] = list(map(lambda g: gmap[g], df.artifactId))\n",
"\n",
"df = df.sort_values(by=['nVersion', 'nArtifactId'])"
"df = df.sort_values(by=[\"nVersion\", \"nArtifactId\"])"
]
},
{
Expand All @@ -47,56 +51,61 @@
"source": [
"import plotly.graph_objects as go\n",
"import code_data_science.palette as palette\n",
"\n",
"colors = palette.colors_by_weight(500)\n",
"\n",
"fig = go.Figure()\n",
"\n",
"# Add a trace to the plot for each category\n",
"for i, category in enumerate(df['nArtifactId'].unique()):\n",
" category_data = df[df['nArtifactId'] == category]\n",
"for i, category in enumerate(df[\"nArtifactId\"].unique()):\n",
" category_data = df[df[\"nArtifactId\"] == category]\n",
"\n",
" fig.add_trace(go.Scatter(\n",
" x=category_data['nArtifactId'],\n",
" y=category_data['nVersion'],\n",
" mode='markers',\n",
" marker=dict(color=colors[i % len(colors)], size=8),\n",
" showlegend=False,\n",
" name=\"\"\n",
" ))\n",
" \n",
" fig.add_trace(go.Violin(\n",
" x=category_data['nArtifactId'],\n",
" y=category_data['nVersion'],\n",
" fillcolor='black',\n",
" opacity=0.15,\n",
" line_color='black',\n",
" showlegend=False,\n",
" width=.7,\n",
" bandwidth=1.2\n",
" ))\n",
" fig.add_trace(\n",
" go.Scatter(\n",
" x=category_data[\"nArtifactId\"],\n",
" y=category_data[\"nVersion\"],\n",
" mode=\"markers\",\n",
" marker=dict(color=colors[i % len(colors)], size=8),\n",
" showlegend=False,\n",
" name=\"\",\n",
" )\n",
" )\n",
"\n",
" fig.add_trace(\n",
" go.Violin(\n",
" x=category_data[\"nArtifactId\"],\n",
" y=category_data[\"nVersion\"],\n",
" fillcolor=\"black\",\n",
" opacity=0.15,\n",
" line_color=\"black\",\n",
" showlegend=False,\n",
" width=0.7,\n",
" bandwidth=1.2,\n",
" )\n",
" )\n",
"\n",
"num_versions = df['nVersion'].nunique()\n",
"num_versions = df[\"nVersion\"].nunique()\n",
"height_per_version = 25\n",
"fig_height = num_versions * height_per_version\n",
"tick_font_size=8\n",
"tick_font_size = 8\n",
"# Customizing the layout\n",
"fig.update_layout(\n",
" title='Artifact Versions in Use',\n",
" xaxis_title='Artifacts',\n",
" yaxis_title='Versions',\n",
" title=\"Artifact Versions in Use\",\n",
" xaxis_title=\"Artifacts\",\n",
" yaxis_title=\"Versions\",\n",
" height=fig_height,\n",
" xaxis=dict(\n",
" tickfont=dict(size=tick_font_size),\n",
" tickmode='array',\n",
" tickmode=\"array\",\n",
" tickvals=list(gmap.values()),\n",
" ticktext=list(gmap.keys())\n",
" ticktext=list(gmap.keys()),\n",
" ),\n",
" yaxis=dict(\n",
" tickfont=dict(size=tick_font_size),\n",
" tickmode='array',\n",
" tickmode=\"array\",\n",
" tickvals=list(vmap.values()),\n",
" ticktext=list(vmap.keys()),\n",
" )\n",
" ),\n",
")\n",
"\n",
"fig.show()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ type: specs.moderne.io/v1beta/visualization
name: io.moderne.DependencyUsageViolin
displayName: Dependency usage
description: >
This notebook shows the distribution of dependencies by version.
See the distribution of dependencies by version.
recipe: org.openrewrite.maven.search.DependencyInsight
dataTable: org.openrewrite.maven.table.DependenciesInUse

0 comments on commit 9125462

Please sign in to comment.