Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions docs/source/adjusting.rst → docs/source/customizing.rst
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 <https://jiffyclub.github.io/palettable/>`_ 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 <https://docs.pydantic.dev/2.0/usage/types/extra_types/color_types/>`_.

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
this snippet:

.. code-block:: python

Expand Down
8 changes: 4 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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) <https://neo4j.com/docs/nvl/current/>`_, and
provides additional features for working with graph data in Python.
Notably, there are convenience methods for importing data from `Pandas DataFrames <https://pandas.pydata.org/>`_,
`Neo4j Graph Data Science <https://neo4j.com/docs/graph-data-science/current/>`_ and `Neo4j Database <https://neo4j.com/docs/python-manual/current/>`.
`Neo4j Graph Data Science <https://neo4j.com/docs/graph-data-science/current/>`_ and `Neo4j Database <https://neo4j.com/docs/python-manual/current/>`_.

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 <https://github.com/neo4j/python-graph-visualization>`_.
If you have a suggestion on how we can improve the library or want to report a problem, you can create a `new issue <https://github.com/neo4j/python-graph-visualization/issues/new>`_.


.. toctree::
Expand All @@ -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
1 change: 1 addition & 0 deletions docs/source/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python-wrapper/src/neo4j_viz/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion python-wrapper/src/neo4j_viz/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions python-wrapper/src/neo4j_viz/visualization_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down