python-streamz / streamz

Real-time stream processing for python
https://streamz.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.23k stars 145 forks source link

ENH: colorful graphs #59

Open CJ-Wright opened 6 years ago

CJ-Wright commented 6 years ago

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).

mrocklin commented 6 years ago

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 < notifications@github.com> 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 .

CJ-Wright commented 6 years ago

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

mrocklin commented 6 years ago

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 < notifications@github.com> 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 commented 6 years ago

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 mrocklin@gmail.com 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 < notifications@github.com> 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 .

jrmlhermitte commented 6 years ago

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?

CJ-Wright commented 6 years ago

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.