streamz icon indicating copy to clipboard operation
streamz copied to clipboard

ENH: colorful graphs

Open CJ-Wright opened this issue 8 years ago • 6 comments

Is it possible to color each node in graphvis? If so we may want to come up with a color scheme such that every node type has a dedicated color for ease of viewing (and making nice graphs for presentations/publications).

CJ-Wright avatar Aug 30 '17 17:08 CJ-Wright

It is. I've often found this page to be a helpful reference for the DOT language: http://www.graphviz.org/doc/info/attrs.html

On Wed, Aug 30, 2017 at 1:48 PM, Christopher J. Wright < [email protected]> wrote:

Is it possible to color each node in graphvis? If so we may want to come up with a color scheme such that every node type has a dedicated color for ease of viewing (and making nice graphs for presentations/publications).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mrocklin/streamz/issues/59, or mute the thread https://github.com/notifications/unsubscribe-auth/AASszDrgR-3fNFMBq2021MvZ__VEi--Nks5sdaBdgaJpZM4PHvuL .

mrocklin avatar Aug 30 '17 19:08 mrocklin

Do we just stuff color information in the graphviz nodes somewhere and expect graphviz to know what to do?

CJ-Wright avatar Aug 30 '17 19:08 CJ-Wright

Yes. It looks like we're using the graphviz library. A quick search yields this documentation: https://graphviz.readthedocs.io/en/stable/manual.html#attributes

On Wed, Aug 30, 2017 at 3:10 PM, Christopher J. Wright < [email protected]> wrote:

Do we just stuff color information in the graphviz nodes somewhere and expect graphviz to know what to do?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mrocklin/streamz/issues/59#issuecomment-326089981, or mute the thread https://github.com/notifications/unsubscribe-auth/AASszCNuxTb26r2Kr9W4SSLbzlQOtF_oks5sdbPCgaJpZM4PHvuL .

mrocklin avatar Aug 30 '17 19:08 mrocklin

You might also find constructing some DOT graphs by hand to be educational if you haven't done it already. It's straightforward and a useful tool for publication.

On Wed, Aug 30, 2017 at 3:15 PM, Matthew Rocklin [email protected] wrote:

Yes. It looks like we're using the graphviz library. A quick search yields this documentation: https://graphviz.readthedocs.io/en/ stable/manual.html#attributes

On Wed, Aug 30, 2017 at 3:10 PM, Christopher J. Wright < [email protected]> wrote:

Do we just stuff color information in the graphviz nodes somewhere and expect graphviz to know what to do?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mrocklin/streamz/issues/59#issuecomment-326089981, or mute the thread https://github.com/notifications/unsubscribe-auth/AASszCNuxTb26r2Kr9W4SSLbzlQOtF_oks5sdbPCgaJpZM4PHvuL .

mrocklin avatar Aug 30 '17 19:08 mrocklin

sounds good. tried it and seems simple (use style=filled with color=clr). Looks like we can use much more, such as shape.

Did you have any coloring in mind? I think differentiating stream methods (map, filter etc) as well as stream subclasses (for example from Stream to DaskStream) could be nice. Maybe it could be something simple such as color for the methods and shape for the subclasses. Since 'method' might be a little ambiguous, here's an example:

from streamz import Stream
s = Stream()
s2 = s.map(lambda x :x + 1)
from streamz import DaskStream
# now objects are Futures
s3 = DaskStream.scatter(s2)
# still a Future
s4 = s3.map(lambda x : x**2)
s5 = DaskStream.gather(s4)

Here s2 and s4 nodes would have the same color but different shape.

Shape would be extremely useful. For example, running filter on a DaskStream would yield a Stream (which is unlikely to be intended use). This could be useful for debugging, where one could use the visualized stream to more quickly see if the data is transforming the way we expect.

What do you think?

jrmlhermitte avatar Sep 24 '17 23:09 jrmlhermitte

I am good with all of those. I'd like to make these (private) attributes of the classes, this way classes which inherent from them/override them would be easy to use. (eg we'd just need to change the shape once for dask streams if they all inherited) I don't have any particular coloring in mind, we may consider drawing from an MPL color cycle since those are more likely to be colorblind safe.

CJ-Wright avatar Sep 25 '17 01:09 CJ-Wright