Node appearance customization
Thenode_properties_kwargs parameter accepts a dictionary of Graphviz node attributes that control visual styling.
Basic styling
Common node properties
The shape of the node. Common values:
"ellipse"- Default oval shape"box"- Rectangle"record"- Rectangle with optional subdivisions (works well with return values)"circle"- Perfect circle"diamond"- Diamond shape"plaintext"- No border, just text
The border color of the node. Accepts hex codes or named colors.
The style of the node. Common values:
"filled"- Filled with fillcolor"solid"- Solid border (default)"dashed"- Dashed border"dotted"- Dotted border"bold"- Bold border"rounded"- Rounded corners (for box shape)
The fill color when
style="filled". Accepts hex codes or named colors.Label customization
Control what information appears in node labels using the decorator parameters.Show or hide argument names
Theshow_argument_name parameter controls whether parameter names are displayed:
- With argument names (default)
- Without argument names
fib(n=5), fib(n=4), etc.Show or hide return values
Theshow_return_value parameter controls whether function return values are displayed on nodes:
- With return values (default)
- Without return values
Record shape with return values
When usingshape="record", return values are displayed in a separate row:
The record shape is particularly useful for clearly separating function calls from their return values.
Ignoring arguments
Theignore_args parameter allows you to hide specific arguments from node labels. This is useful when certain parameters are constant or clutter the visualization.
Basic usage
coin_change(amount=5, n=3) instead of coin_change(coins=[1, 2, 5], amount=5, n=3)
Multiple ignored arguments
Combining with other options
coin_change(5, 3) => 4 (clean and compact)
Complete customization examples
Example 1: Fibonacci with styled nodes
Example 2: Combinations with minimal labels
Example 3: Clean display without clutter
Available Graphviz attributes
You can use any valid Graphviz node attribute innode_properties_kwargs. Here are some commonly used ones:
| Attribute | Description | Example Values |
|---|---|---|
shape | Node shape | "ellipse", "box", "record", "circle", "diamond" |
color | Border color | "red", "#f57542" |
fillcolor | Fill color (requires style="filled") | "lightblue", "#ccffcc" |
style | Node style | "filled", "solid", "dashed", "bold", "rounded" |
fontname | Font family | "Helvetica", "Arial", "Courier" |
fontsize | Font size in points | "12", "14", "16" |
fontcolor | Text color | "black", "white", "#333333" |
penwidth | Border width | "1.0", "2.5" |
For a complete list of Graphviz node attributes, see the Graphviz documentation.
Tips for effective visualizations
Use record shape for clarity
The
"record" shape works particularly well with show_return_value=True, creating a clear visual separation.Hide verbose arguments
Use
ignore_args to hide large data structures or constant parameters that clutter the display.Choose colors wisely
Use contrasting colors for borders and fills. Light fill colors with dark borders often work well.