Giter Club home page Giter Club logo

blender-graphs's Introduction

Graphs in Blender

Produces high-quality 3D visualizations of network data.

######For interactive 3D graph visualization, check out the igraph project.

Examples

Quinoline reaction pathway in a flask

Breadth-first search depiction

Usage

To use standard parameters for everything, simply run

sh draw_network.sh *adjacency_list*

where adjacency_list is either a file or a string containing a json adjacency list of the format

[["source_1", "target_1"], ["source_2", "target_2"], ...]

The node identifiers can be anything, so long as they are self consistent. For example,

sh draw_network.sh "[[1,2],[2,3],[3,4],[4,1],[2,5],[5,4]]"

will open blender with a 3D visualization of this network (see the "pinwheel" sample).

Advanced Usage

For more control, you can break the process into two parts. Running

python force_directed_layout.py "[[1,2],[2,3],[3,4]]" > network.json

produces a network.json file containing

{
    "edges": [
        { "source": "1", "target": "2" },
        { "source": "2", "target": "3" },
        { "source": "3", "target": "4" }
    ],
    "nodes": {
        "1": { "location": [ -3.290, -6.258, -8.930 ] },
        "2": { "location": [ -1.115, -2.167, -3.103 ] },
        "3": { "location": [ 1.188, 2.173, 3.096 ] },
        "4": { "location": [ 3.348, 6.252, 8.937 ] }
    }
}

If you want to run your own location-generating code, the Blender script will run on any network.json file with this format (Note: make sure the file is called "network.json"!). For some control of colors, you can specify a few common options directly in the .json by specifying a "color" property for each node. For example, you can edit the above to:

{
    "edges": [
        { "source": "1", "target": "2" },
        { "source": "2", "target": "3" },
        { "source": "3", "target": "4" }
    ],
    "nodes": {
        "1": { "location": [ -3.290, -6.258, -8.930 ], "color": "red" },
        "2": { "location": [ -1.115, -2.167, -3.103 ], "color": "gray" },
        "3": { "location": [ 1.188, 2.173, 3.096 ], "color": "blue" },
        "4": { "location": [ 3.348, 6.252, 8.937 ], "color": "purple" }
    }
}

If color is not specified, random colors will be chosen. For more control, open the network_to_blender.py file directly and edit this logic yourself. It's a very short script, so you should have no problem editing it. The network_to_blender.py script can also be easily edited to change node shapes and sizes, or to disable edge arrows.

Once you're happy with your coloring, run

blender -P network_to_blender.py

which will open a blender gui with the chosen graph.

Splitting this process into two commands gives you access to some additional graph-generation parameters.

python force_directed_layout.py --force-strength 10 --2D "[[1,2],[2,3],[3,4]]"
  • --force-strength determines the separation between nodes
  • --2D confines the network layout to two dimensions

Random layout is a useful starting point in cases where you want to create your own layout for artistic reasons.

python random_layout.py --edge-length 15 --separation 3 --density 60 --concentric --2D "[[1,2],[2,3],[3,4]]"
  • --edge-length is the maximum length of a network edge
  • --separation is the minimum distance between any two nodes
  • --density attempts to compact the nodes spherically if non-zero
  • --concentric places the root node at the center of the network
  • --2D confines the network layout to two dimensions

Layered layout will arrange the network according to distance from a designated node. See the subfolder for usage.

blender-graphs's People

Contributors

patrickfuller avatar karsekar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.