Skip to content

Commit 9550e70

Browse files
adamnschFlorentinD
andcommitted
Add docs on color types
Co-Authored-By: Florentin Dörre <[email protected]>
1 parent b542e2c commit 9550e70

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

docs/source/customizing.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,18 @@ the first positional argument.
3737
By default the Neo4j color palette that works for both light and dark mode will be used.
3838
If you want to use a different color palette, you can pass a dictionary or iterable of colors as the ``colors``
3939
parameter.
40-
You can for example use the color palettes from the `palettable library <https://jiffyclub.github.io/palettable/>`_ as in
41-
the following example:
40+
A color value can for example be either strings like "blue", or hexadecimal color codes like "#FF0000", or even a tuple of RGB values like (255, 0, 255).
41+
Here is an example of providing a list of custom colors to the ``color_nodes`` method:
42+
43+
.. code-block:: python
44+
45+
# VG is a VisualizationGraph object
46+
VG.color_nodes("caption", ["red", "#7fffd4", (255, 255, 255, 0.5), "hsl(270, 60%, 70%)"])
47+
48+
The full set of allowed values for colors are listed `here <https://docs.pydantic.dev/2.0/usage/types/extra_types/color_types/>`_.
49+
50+
Instead of defining your own colors, you could also for example use the color palettes from the `palettable library <https://jiffyclub.github.io/palettable/>`_ as in
51+
this snippet:
4252

4353
.. code-block:: python
4454

python-wrapper/src/neo4j_viz/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Node(BaseModel, extra="allow"):
3737
)
3838
#: The size of the node as radius in pixel
3939
size: Optional[RealNumber] = Field(None, ge=0, description="The size of the node as radius in pixel")
40-
#: The color of the node
40+
#: The color of the node. Allowed input is for example "#FF0000", "red" or (255, 0, 0)
4141
color: Optional[ColorType] = Field(None, description="The color of the node")
4242
#: Whether the node is pinned in the visualization
4343
pinned: Optional[bool] = Field(None, description="Whether the node is pinned in the visualization")

python-wrapper/src/neo4j_viz/relationship.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Relationship(BaseModel, extra="allow"):
4141
caption_size: Optional[Union[int, float]] = Field(
4242
None, gt=0.0, serialization_alias="captionSize", description="The size of the caption text"
4343
)
44-
#: The color of the relationship
44+
#: The color of the relationship. Allowed input is for example "#FF0000", "red" or (255, 0, 0)
4545
color: Optional[ColorType] = Field(None, description="The color of the relationship")
4646

4747
@field_serializer("color")

python-wrapper/src/neo4j_viz/visualization_graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def color_nodes(self, property: str, colors: Optional[ColorsType] = None, overri
205205
colors:
206206
The colors to use for the nodes. If a dictionary is given, it should map from property to color.
207207
If an iterable is given, the colors are used in order.
208+
Allowed color values are for example “#FF0000”, “red” or (255, 0, 0) (full list: https://docs.pydantic.dev/2.0/usage/types/extra_types/color_types/).
208209
The default colors are the Neo4j graph colors.
209210
override:
210211
Whether to override existing colors of the nodes, if they have any.

0 commit comments

Comments
 (0)