-
Notifications
You must be signed in to change notification settings - Fork 162
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
Animated Network Visualization Example #167
Conversation
Hello @filipinascimento! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-03-03 18:17:46 UTC |
Codecov Report
@@ 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
|
There was a problem hiding this 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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, good catch @dmreagan!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
############################################################################### | ||
# 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. |
There was a problem hiding this comment.
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, | ||
) |
There was a problem hiding this comment.
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) + |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as before
- Removes unused variables
Thank you @filipinascimento ! |
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.