Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(graphviz): support custom node and edge attributes in ibis.visualize #8510

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

peter-gy
Copy link
Contributor

@peter-gy peter-gy commented Feb 29, 2024

Description of changes

Enables the customization of graphviz graphs produced by ibis.visualize by exposing node_attr and edge_attr as optional keyword arguments. Changing node shapes, fonts and font sizes can be highly useful when dealing with complex expression graphs.

The default attributes (DEFAULT_NODE_ATTRS, DEFAULT_EDGE_ATTRS) are still considered, but the user-defined ones will take precedence.

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Do you have a sweet image you can show that takes advantage of these shiny new parameters?

@cpcloud cpcloud added this to the 9.0 milestone Mar 1, 2024
@cpcloud cpcloud added the feature Features or general enhancements label Mar 1, 2024
@cpcloud cpcloud changed the title feat: support custom node and edge attributes in ibis.visualize feat(graphviz): support custom node and edge attributes in ibis.visualize Mar 1, 2024
@cpcloud cpcloud merged commit ee821b1 into ibis-project:main Mar 1, 2024
77 checks passed
@peter-gy
Copy link
Contributor Author

peter-gy commented Mar 1, 2024

Nice!

Do you have a sweet image you can show that takes advantage of these shiny new parameters?

Of course. From now on, nothing stops us from committing cardinal sins like using Comic Sans MS for edge labels :)

import ibis


left = ibis.table(dict(a="int64", b="string"), name="left")
right = ibis.table(dict(b="string", c="int64", d="string"), name="right")
expr = (
    left.inner_join(right, "b")
    .select(left.a, b=right.c, c=right.d)
    .mutate(
        arrays=ibis.array([1, 2, 3]),
    )
)
expr.visualize(
	label_edges=True,
	node_attr={"shape":"hexagon", "color":"green", "fontname": "Roboto Mono"},
	edge_attr={"fontsize": "12", "fontname": "Comic Sans MS"}
)

nice-font-right

@peter-gy peter-gy deleted the feat/custom-viz-attributes branch March 1, 2024 13:21
@lostmygithubaccount
Copy link
Member

that's going in the 9.0 blog, thanks! 😂

@cpcloud
Copy link
Member

cpcloud commented Mar 1, 2024

I'm adding a how-to for ibis.expr.visualize.to_graph and will add this image there.

@peter-gy
Copy link
Contributor Author

peter-gy commented Mar 1, 2024

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants