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

Add Chord element #2138

Merged
merged 16 commits into from
Feb 14, 2018
Merged

Add Chord element #2138

merged 16 commits into from
Feb 14, 2018

Conversation

philippjfr
Copy link
Member

As outlined in #2137 this PR adds support for a Chord element. So far this is just a WIP, but basically this just extends the existing Graph element to lay things out in a circle and draw bezier splines between the nodes. The next step will be to allow scaling the line thickness by a value in a separate PR, which will allow scaling the chords representing the edges between nodes and then start drawing the bands around the circle.

Progress for what is supported can be tracked in: https://anaconda.org/philippjfr/chord/notebook

@philippjfr philippjfr added type: feature A major new feature status: WIP labels Nov 18, 2017
@jbednar
Copy link
Member

jbednar commented Nov 18, 2017

Nice! We sure need the automatic viewport padding...

@philippjfr
Copy link
Member Author

philippjfr commented Nov 20, 2017

Since a Chord plot is always drawn on a unit circle I've now added some default padding which can be adjusted by using the .redim.range to adjust the range of the node x and y dimensions. This means it now provides reasonable defaults, while still letting you override them (the bkcharts version hardcoded the ranges), here's the default viewport of a full ChordPlot with labels:

screen shot 2017-11-20 at 10 05 24 pm

@philippjfr
Copy link
Member Author

This PR is now feature complete, and behaves how I think it should. The upcoming 0.12.11 bokeh release will fix a bug updating the colormapping of the edges, which shouldn't be an issue as that will be released long before our next release. It's now just missing reference doc entries and plenty of unit tests.

@philippjfr
Copy link
Member Author

Ready to review and merge.

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

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

Looks great!

"outputs": [],
"source": [
"links = pd.DataFrame(data['links'])\n",
"print(links.head(3))\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to see this cell split:

links = pd.DataFrame(data['links'])
links.head(3)

Then:

hv.Chord(links)

I also notice the kernel metadata is still present in the notebooks. Could you please clear that out?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure.

@@ -235,6 +235,23 @@ def circular_layout(nodes):
return (x, y, nodes)


def quadratic_bezier(start, end, c0=(0, 0), c1=(0, 0), steps=50):
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally this should be handled by the plotting extension. The main advantage I see of us doing this is that it helps consistency between matplotlib/bokeh. That said, plotting libraries might have more performant/robust code (though this is using numpy so it shouldn't be too slow).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll aim to make a PR against bokeh that allows using the bezier glyph as the edge renderer on a graph renderer, but that might be a little while.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be nice. I might actually prefer holoviews handling this if the available bezier definitions in matplotlib/bokeh don't match up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Afaik they do match.

@@ -9,6 +9,8 @@
from holoviews.plotting import comms

try:
from matplotlib import pyplot
pyplot.switch_backend('agg')
Copy link
Contributor

Choose a reason for hiding this comment

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

I am assuming this isn't directly related to this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just part of shuffling tests around.

@jlstevens
Copy link
Contributor

Made a few comments but overall it looks good. Once they are addressed, the merge conflict is resolved and the tests are green, I'm happy to merge.

@philippjfr
Copy link
Member Author

Made the requested change to the notebooks and resolved the merge conflicts. Ready to merge when tests pass.

@jlstevens
Copy link
Contributor

Looks good. Merging.

@jlstevens jlstevens merged commit 3630fb7 into master Feb 14, 2018
@philippjfr philippjfr deleted the chord_graph branch February 16, 2018 12:55
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature A major new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants