Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt the tutorial to the new mapper API #8

Merged
merged 8 commits into from
Feb 26, 2020

Conversation

wreise
Copy link
Contributor

@wreise wreise commented Jan 22, 2020

gtda.mappers.visualization:plot_static_mapper_graph has less flexibility regarding colors and the colormaps. Hence, the colors are updated directly on the figure.

@wreise wreise marked this pull request as ready for review January 22, 2020 11:17
@wreise wreise requested a review from lewtun January 22, 2020 11:19
@WeilerP
Copy link

WeilerP commented Jan 22, 2020

There are a few flake8 linting violations in the notebook. For consistency, these could (or should?) be resolved. For example:

plotly_kwargs = {'node_trace_marker_colorscale': None,
                'node_trace_marker_showscale': False
                }

instead of

plotly_kwargs = {'node_trace_marker_colorscale': None,
                 'node_trace_marker_showscale': False}

@WeilerP
Copy link

WeilerP commented Jan 22, 2020

If I am not mistaken, the following code is reused in almost all cells:

# get cluster member indices
node_elements = graph["node_metadata"]["node_elements"]
# configure choice of layout (x,z values)
layout = np.array([np.mean(coords[el], axis=0)[[0, 2]] for el in node_elements])
# define node coloring
node_colors = np.array([data.loc[el, "color"].value_counts().index[0] for el in node_elements])
plotly_kwargs = {'node_trace_marker_colorscale': None,
                'node_trace_marker_showscale': False
                }

# initialise and display figure
fig = plot_static_mapper_graph(pipeline, coords,
                               layout, plotly_kwargs=plotly_kwargs)
fig.update_traces(patch={'hoverlabel_bgcolor': node_colors,
                   'marker_color': node_colors})
fig.show(config={'scrollZoom':True})

For readability, I think this part should be defined either once as a function in the notebook or in a separate utils.py file.

Copy link
Collaborator

@ulupo ulupo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed some now unnecessary requirements, it should be ready to merge!

@ulupo ulupo merged commit d682bac into giotto-ai:master Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants