Skip to content

Commit b741e24

Browse files
adamnschFlorentinD
andcommitted
Improve ColorSpace docs
Co-Authored-By: Florentin Dörre <florentin.dorre@neotechnology.com>
1 parent a9cde0d commit b741e24

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. autoenum:: neo4j_viz.colors.ColorSpace
2+
:members:

docs/source/customizing.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ The ``color_nodes`` method
3636

3737
By calling the :meth:`neo4j_viz.VisualizationGraph.color_nodes` method, you can color nodes based on a
3838
node field or property (members of the `Node.properties` map).
39-
It's possible to color the nodes based on a discrete or continuous color space. In the discrete case, a new
40-
color from the `colors` provided is assigned to each unique value of the node field/property.
39+
40+
It's possible to color the nodes based on a discrete or continuous color space (see :doc:`ColorSpace <./api-reference/colors>`).
41+
In the discrete case, a new color from the `colors` provided is assigned to each unique value of the node field/property.
4142
In the continuous case, the `colors` should be a list of colors representing a range that are used to
4243
create a gradient of colors based on the values of the node field/property.
4344

@@ -50,8 +51,8 @@ If some nodes already have a ``color`` set, you can choose whether or not to ove
5051
parameter.
5152

5253

53-
By discrete node property (field)
54-
*********************************
54+
By discrete color space
55+
***********************
5556

5657
To not use the default colors, we can provide a list of custom colors based on the discrete node field "caption" to the ``color_nodes`` method:
5758

@@ -86,8 +87,8 @@ To avoid that, you could use a larger palette or extend one with additional colo
8687
to do the latter.
8788

8889

89-
By continuous node property (field)
90-
***********************************
90+
By continuous color space
91+
*************************
9192

9293
To not use the default colors, we can provide a list of custom colors representing a range to the ``color_nodes`` method:
9394

python-wrapper/src/neo4j_viz/colors.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22
from enum import Enum
33
from typing import Any, Union
44

5+
import enum_tools
56
from pydantic_extra_types.color import ColorType
67

78
ColorsType = Union[dict[Any, ColorType], Iterable[ColorType]]
89

910

11+
@enum_tools.documentation.document_enum
1012
class ColorSpace(Enum):
13+
"""
14+
Describes the type of color space used by a color palette.
15+
"""
16+
1117
DISCRETE = "discrete"
18+
"""
19+
This category describes a color palette that is a collection of different colors that are not necessarily related to
20+
each other. Discrete color spaces are suitable for categorical data, where each unique category is represented by a
21+
different color.
22+
"""
1223
CONTINUOUS = "continuous"
24+
"""
25+
This category describes a color palette that is a range/gradient of colors between two or more colors. Continuous
26+
color spaces are suitable for continuous data (typically floats), where values can change smoothly.
27+
"""
1328

1429

1530
# Comes from https://neo4j.design/40a8cff71/p/5639c0-color/t/page-5639c0-79109681-33

0 commit comments

Comments
 (0)