Skip to content

Commit

Permalink
Add mypy ignore comments for matplotlib attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilkilic committed Nov 22, 2023
1 parent ad5c5e6 commit b6d5a13
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bluecellulab/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def plot_graph(G: nx.Graph, node_size: float = 400, edge_width: float = 0.4, nod
populations = list(set([cell_id.population_name for cell_id in G.nodes()]))

# Create a color map for each population
color_map = plt.cm.tab20(np.linspace(0, 1, len(populations)))
color_map = plt.cm.tab20(np.linspace(0, 1, len(populations))) # type: ignore[attr-defined]
population_color = dict(zip(populations, color_map))

# Create node colors based on their population
node_colors = [population_color[node.population_name] for node in G.nodes()]

# Extract weights for edge color mapping
edge_weights = [d['weight'] for _, _, d in G.edges(data=True)]
edge_colors = plt.cm.Greens(np.interp(edge_weights, (min(edge_weights), max(edge_weights)), (0.3, 1)))
edge_colors = plt.cm.Greens(np.interp(edge_weights, (min(edge_weights), max(edge_weights)), (0.3, 1))) # type: ignore[attr-defined]

# Create positions using spring layout for the entire graph
pos = nx.spring_layout(G, k=node_distance)
Expand Down

0 comments on commit b6d5a13

Please sign in to comment.