diff --git a/docs/source/adjusting.rst b/docs/source/customizing.rst similarity index 88% rename from docs/source/adjusting.rst rename to docs/source/customizing.rst index bb39d5c9..397997e9 100644 --- a/docs/source/adjusting.rst +++ b/docs/source/customizing.rst @@ -1,5 +1,5 @@ -Adjusting the visualization -=========================== +Customizing the visualization +============================= Once created, a :doc:`VisualizationGraph object <./api-reference/visualization-graph>` can be modified in various ways to adjust what the visualization looks like the next time you render it. @@ -37,8 +37,18 @@ the first positional argument. By default the Neo4j color palette that works for both light and dark mode will be used. If you want to use a different color palette, you can pass a dictionary or iterable of colors as the ``colors`` parameter. -You can for example use the color palettes from the `palettable library `_ as in -the following example: +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). +Here is an example of providing a list of custom colors to the ``color_nodes`` method: + +.. code-block:: python + + # VG is a VisualizationGraph object + VG.color_nodes("caption", ["red", "#7fffd4", (255, 255, 255, 0.5), "hsl(270, 60%, 70%)"]) + +The full set of allowed values for colors are listed `here `_. + +Instead of defining your own colors, you could also for example use the color palettes from the `palettable library `_ as in +this snippet: .. code-block:: python diff --git a/docs/source/index.rst b/docs/source/index.rst index 525e10be..09d3b06e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,10 +12,10 @@ The library allows you to visualize graph data interactively in Python using a s The library wraps the `Neo4j Visualization JavaScript library (NVL) `_, and provides additional features for working with graph data in Python. Notably, there are convenience methods for importing data from `Pandas DataFrames `_, -`Neo4j Graph Data Science `_ and `Neo4j Database `. +`Neo4j Graph Data Science `_ and `Neo4j Database `_. -The source code is available on https://github.com/neo4j/python-graph-visualization[GitHub]. -If you have a suggestion on how we can improve the library or want to report a problem, you can create a https://github.com/neo4j/python-graph-visualization/issues/new[new issue]. +The source code is available on `GitHub `_. +If you have a suggestion on how we can improve the library or want to report a problem, you can create a `new issue `_. .. toctree:: @@ -26,6 +26,6 @@ If you have a suggestion on how we can improve the library or want to report a p getting-started.nblink integration.rst rendering.rst - adjusting.rst + customizing.rst api-reference/index.rst tutorials/index.rst diff --git a/docs/source/integration.rst b/docs/source/integration.rst index 53ba45da..9e91a263 100644 --- a/docs/source/integration.rst +++ b/docs/source/integration.rst @@ -11,6 +11,7 @@ Pandas DataFrames ----------------- The ``neo4j-viz`` library provides a convenience method for importing data from Pandas DataFrames. +These DataFrames can be created from many sources, such as CSV files or :doc:`Snowflake tables<./tutorials/snowpark-example>`. It requires and additional dependency to be installed, which you can do by running: .. code-block:: bash diff --git a/python-wrapper/src/neo4j_viz/node.py b/python-wrapper/src/neo4j_viz/node.py index be1bf2e4..8718a497 100644 --- a/python-wrapper/src/neo4j_viz/node.py +++ b/python-wrapper/src/neo4j_viz/node.py @@ -37,7 +37,7 @@ class Node(BaseModel, extra="allow"): ) #: The size of the node as radius in pixel size: Optional[RealNumber] = Field(None, ge=0, description="The size of the node as radius in pixel") - #: The color of the node + #: The color of the node. Allowed input is for example "#FF0000", "red" or (255, 0, 0) color: Optional[ColorType] = Field(None, description="The color of the node") #: Whether the node is pinned in the visualization pinned: Optional[bool] = Field(None, description="Whether the node is pinned in the visualization") diff --git a/python-wrapper/src/neo4j_viz/relationship.py b/python-wrapper/src/neo4j_viz/relationship.py index 040da1d9..b5f4c640 100644 --- a/python-wrapper/src/neo4j_viz/relationship.py +++ b/python-wrapper/src/neo4j_viz/relationship.py @@ -41,7 +41,7 @@ class Relationship(BaseModel, extra="allow"): caption_size: Optional[Union[int, float]] = Field( None, gt=0.0, serialization_alias="captionSize", description="The size of the caption text" ) - #: The color of the relationship + #: The color of the relationship. Allowed input is for example "#FF0000", "red" or (255, 0, 0) color: Optional[ColorType] = Field(None, description="The color of the relationship") @field_serializer("color") diff --git a/python-wrapper/src/neo4j_viz/visualization_graph.py b/python-wrapper/src/neo4j_viz/visualization_graph.py index a017910c..a21bea32 100644 --- a/python-wrapper/src/neo4j_viz/visualization_graph.py +++ b/python-wrapper/src/neo4j_viz/visualization_graph.py @@ -205,6 +205,7 @@ def color_nodes(self, property: str, colors: Optional[ColorsType] = None, overri colors: The colors to use for the nodes. If a dictionary is given, it should map from property to color. If an iterable is given, the colors are used in order. + 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/). The default colors are the Neo4j graph colors. override: Whether to override existing colors of the nodes, if they have any.