Change node color based on properties - neo4j

Nicky Feller picture Nicky Feller · Nov 1, 2015 · Viewed 11.4k times · Source

I want to change the color of my nodes based on their properties:

Say I have many "Person" nodes. And I want those who live in New York to be red and those who live in Los Angeles to be blue. How would I write that. In cypher or in py2neo?

Answer

jjaderberg picture jjaderberg · Nov 1, 2015

The styling of nodes and relationships in Neo4j Browser is controlled by a graph style sheet (GRASS), a cousin of CSS. You can view the current style by typing :style in the browser. To edit it, you can click on nodes and relationships and pick colors and sizes, or you can view the style sheet (:style), download it, make changes, and drag-n-drop it back into the view window.

Unfortunately for your case, color can only be controlled a) for all nodes and all relationships or b) for nodes by label and relationships by type. Properties can only be used for the text displayed on the node/rel.