Skip to content

kiwirafe/springpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Springpy

Springpy visualises a distance matrix.

While similar to the "Spring Function" in qgraph in R and networkx in Python, springpy provides a simple way to visualize a distance matrix using the Fruchterman Reingold method. Springpy allows you to create a spring graph or animate a distance matrix in just one line of code.

Download

pip3 install springpy

Usage

import springpy as sp
matrix = [[0         , 0.00638545,  0.28778769],
          [0.00638545, 0         ,  0.21402251],
          [0.28778769, 0.21402251,  0         ]]

# Show a matplotlib animation
sp.animate(matrix)

# Save to video (Default Name:"spring_result.mp4")
sp.animate(matrix, save=True)

# Show a matplotlib graph
sp.graph(matrix)

# Save the graph(Default Name:"spring_result.jpg")
sp.graph(matrix, save=True)

Input: A distance matrix embedded into a 2D Python List.

Demonstration:

Data: dmatrix.csv Code: example.py

Result(animation & video):

springpy_result.mp4

Result(graph):

springpy_result

Modify Default Variables

Calculation Variables

import springpy as sp

# Width of the graph, default 100px
sp.w = 100
# Height of the graph, default 100px
sp.h = 100
# Cool down delta, default 0.975
sp.delta = 0.975
# The eplison, if the change is smaller than this value, then stop iterating, default 5
sp.eplison = 10
# Max iteration, the maximum number of iterations, default 500
sp.MaxIter = 500

sp.animate variables:

sp.animate(self, matrix, save=False, interval=100, VideoName="springpy_result.mp4"):
"""
:param save: whether to save the video, default False
:param interval: the interval between frames, default 100
:param VideoName: the name of the video for the result, default "springpy_result.gif". 
                  Note that this name must include the suffix (ie .gif)
""" 

sp.graph variables:

sp.graph(self, matrix, save=False, ImageName = "springpy_result.jpg"):
"""
:param save: whether to save the graph, default False
:param VideoName: the name of the graph for the result, default "springpy_result.jpg". 
                  Note that this name must include the suffix (ie .jpg or .png)
""" 

About

A Network Visualizer in Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy