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

Animated Network Visualization Example #167

Merged
merged 7 commits into from
Mar 3, 2020

Conversation

filipinascimento
Copy link
Contributor

This is a work in progress demo for animated network visualization.

Two modes are implemented, one in which the positions of nodes are defined by a force-directed layout algorithm; and another with the positions of the network being progressively displaced by random increments.

image

image

@pep8speaks
Copy link

pep8speaks commented Feb 26, 2020

Hello @filipinascimento! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 116:1: E302 expected 2 blank lines, found 1

Comment last updated at 2020-03-03 18:17:46 UTC

@codecov
Copy link

codecov bot commented Feb 26, 2020

Codecov Report

Merging #167 into master will increase coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #167      +/-   ##
========================================
+ Coverage   87.93%    88%   +0.06%     
========================================
  Files          17     17              
  Lines        4145   4219      +74     
  Branches      514    527      +13     
========================================
+ Hits         3645   3713      +68     
- Misses        363    367       +4     
- Partials      137    139       +2
Impacted Files Coverage Δ
fury/actor.py 92.62% <0%> (-0.47%) ⬇️
fury/ui.py 85.66% <0%> (+0.06%) ⬆️
fury/primitive.py 81.48% <0%> (+5.87%) ⬆️

@skoudoro skoudoro added this to the v0.5.0 milestone Feb 26, 2020
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Thank you for this PR @filipinascimento! Really cool tutorial!

I know it is work in progress, but I added some quick comments below to fix. Thanks!

# Shaders Trick


mapper = lines_actor.GetMapper()
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove this line and the title above (Shader Trick)

# Run every 200 milliseconds
showm.add_timer_callback(True, 16, timer_callback)

showm.start()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace this line by

interactive = False

if interactive:
    showm.start()

window.record(showm.scene, size=(900, 768), out_path="viz_animated_networks.png")


###############################################################################
# This example can be improved by adding some interactivy with slider,
# picking, etc. Play with it, improve it!
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove this comment block

Comment on lines 110 to 114
lines_actor = actor.line(np.zeros((len(edges), 2, 3)),
colors=edges_colors, lod=False)
lines_actor.GetProperty().SetRenderLinesAsTubes(1)
lines_actor.GetProperty().SetLineWidth(5)
lines_actor.GetProperty().SetOpacity(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be done in one line like:

lines_actor = actor.line(np.zeros((len(edges), 2, 3)), colors=edges_colors, lod=False, linewidth=5, fake_tube=True)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, good catch @dmreagan!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, but I remember we discussed that their behavior are different. If I'm not mistaken, one uses fury implementation of fake tubes and the other uses vtk implementation. The shaders are different. Anyway I will check this again and make the other proposed changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh they are the same. Thanks. will make the change.

@skoudoro skoudoro changed the title WIP: Animated Network Visualization Example [WIP] Animated Network Visualization Example Feb 26, 2020
###############################################################################
# Lets create our edges now. They will indicate a citation between two nodes.
# OF course, the colors of each edges will be an interpolation between the two
# node that it connects.
Copy link
Contributor

Choose a reason for hiding this comment

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

nodes

radii=radii*0.5,
theta=8,
phi=8,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove comma and push parenthesis up

x1, y1, z1 = pos[vertex1]
x2, y2, z2 = pos[vertex2]
distance = math.sqrt(
(x2-x1)*(x2-x1) +
Copy link
Contributor

Choose a reason for hiding this comment

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

pep8

rz = (z2-z1)/distance
Fx = -b*rx/distance/distance
Fy = -b*ry/distance/distance
Fz = -b*rz/distance/distance
Copy link
Contributor

Choose a reason for hiding this comment

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

pep8 issues from line 156 to line 164

x1, y1, z1 = pos[vFrom]
x2, y2, z2 = pos[vTo]
distance = math.sqrt(
(x2-x1)*(x2-x1) +
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before

@skoudoro skoudoro changed the title [WIP] Animated Network Visualization Example Animated Network Visualization Example Mar 3, 2020
@Garyfallidis
Copy link
Contributor

Thank you @filipinascimento !

@Garyfallidis Garyfallidis merged commit de4fd4f into fury-gl:master Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants