GithubHelp home page GithubHelp logo

Creating "group" for nodes about pyvis HOT 3 CLOSED

westhealth avatar westhealth commented on August 30, 2024
Creating "group" for nodes

from pyvis.

Comments (3)

kk-hiraskar avatar kk-hiraskar commented on August 30, 2024 8

How to show legend for the colors ?
[or]
how to get what color is applied to group number?

Because without legend interpretation, difficult to represent the graph

from pyvis.

boludo00 avatar boludo00 commented on August 30, 2024 1

Hi, you can just use the "group" keyword arg when adding nodes.

from pyvis.network import Network

g = Network()
g.add_node(0, group=0)
g.add_node(1, group=0)
g.add_node(2, group=1)
g.add_node(3, group=1)
g.add_node(4, group=2)
g.add_node(5, group=2)
g.show("groups.html")

Result:
image

from pyvis.

mtfang avatar mtfang commented on August 30, 2024

@kk-hiraskar I felt your pain today, but found the solution. Better late than never...

The solution is to use the underlying visJS library. You can find an example called "Custom Groups" in the visJS examples library. Pass through your group parameters via network.Network.set_options() where taking their example you'd have something like:

nt = Network()
nt.set_options("""
const options = {
groups: {
    diamonds: {
      color: { background: "red", border: "white" },
      shape: "diamond",
    },
    dotsWithLabel: {
      label: "I'm a dot!",
      shape: "dot",
      color: "cyan",
    },
    mints: { color: "rgb(0,255,140)" },
    icons: {
      shape: "icon",
      icon: {
        face: "FontAwesome",
        code: "\uf0c0",
        size: 50,
        color: "orange",
      }
    }
}
""")

from pyvis.

Related Issues (20)

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.