Skip to content

Commit d1369ed

Browse files
committed
ENH(plot): LEGEND +Overwrites+Failed+Canceled; abitrary URLs; ...
+ enh: link to arbitrary URLs (default: RTD). + enh: better tooltips. + doc legend().
1 parent ffee34b commit d1369ed

File tree

2 files changed

+146
-92
lines changed

2 files changed

+146
-92
lines changed

docs/source/images/GraphtikLegend.svg

Lines changed: 85 additions & 55 deletions
Loading

graphtik/plot.py

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,20 @@ def render_pydot(dot: pydot.Dot, filename=None, show=False, jupyter_render: str
360360
return dot
361361

362362

363-
def legend(filename=None, show=None, jupyter_render: Mapping = None):
364-
"""Generate a legend for all plots (see :meth:`.Plotter.plot()` for args)"""
363+
def legend(
364+
filename=None,
365+
show=None,
366+
jupyter_render: Mapping = None,
367+
arch_url="https://graphtik.readthedocs.io/en/latest/arch.html",
368+
):
369+
"""
370+
Generate a legend for all plots (see :meth:`.Plotter.plot()` for args)
371+
372+
:param arch_url:
373+
the url to the architecture section explaining *graphtik* glassary.
374+
375+
See :func:`render_pydot` for the rest argyments.
376+
"""
365377

366378
_monkey_patch_for_jupyter(pydot)
367379

@@ -378,55 +390,67 @@ def legend(filename=None, show=None, jupyter_render: Mapping = None):
378390
379391
operation [shape=oval fontname=italic
380392
tooltip="A function with needs & provides."
381-
URL="arch.html#term-operation"];
393+
URL="%(url)s#term-operation"];
382394
insteps [penwidth=3 label="execution step" fontname=italic
383-
tooltip="Execution plan included this operation/eviction."
384-
URL="arch.html#term-execution-steps"];
395+
tooltip="Either an operation or ean eviction-instruction."
396+
URL="%(url)s#term-execution-steps"];
385397
executed [style=filled fillcolor=wheat fontname=italic
386-
tooltip="Step executed."
387-
URL="arch.html#term-solution"];
388-
operation -> insteps -> executed [style=invis];
398+
tooltip="Step executed succesfully."
399+
URL="%(url)s#term-solution"];
400+
failed [style=filled fillcolor=LightCoral fontname=italic
401+
tooltip="Step failed."
402+
URL="%(url)s#term-endurance"];
403+
canceled [style=filled fillcolor=Grey fontname=italic
404+
tooltip="Canceled step due to failures upstream."
405+
URL="%(url)s#term-endurance"];
406+
operation -> insteps -> executed -> failed -> canceled [style=invis];
389407
390408
data [shape=rect
391409
tooltip="Any data not given or asked."
392-
URL="arch.html#term-graph"];
410+
URL="%(url)s#term-graph"];
393411
input [shape=invhouse
394412
tooltip="Solution value given into the computation."
395-
URL="arch.html#term-inputs"];
413+
URL="%(url)s#term-inputs"];
396414
output [shape=house
397415
tooltip="Solution value asked from the computation."
398-
URL="arch.html#term-outputs"];
416+
URL="%(url)s#term-outputs"];
399417
inp_out [shape=hexagon label="inp+out"
400-
tooltip="Data both given and asked (overwrites)."
401-
URL="arch.html#term-overwrites"];
418+
tooltip="Data both given and asked."
419+
URL="%(url)s#term-netop"];
402420
evicted [shape=rect penwidth=3 color="#990000"
403-
tooltip="Data erased from solution to save memory."
404-
URL="arch.html#term-evictions"];
421+
tooltip="Data erased from solution, to save memory."
422+
URL="%(url)s#term-evictions"];
405423
sol [shape=rect style=filled fillcolor=wheat label="in solution"
406-
tooltip="Solution contains a value for this data."
407-
URL="arch.html#term-solution"];
408-
data -> input -> output -> inp_out -> evicted -> sol [style=invis];
409-
410-
e1 [style=invis];
411-
e1 -> e2;
412-
e2 [color=invis label="dependency"
413-
tooltip="Regular `needs` or a `provides`."
414-
URL="arch.html#term-needs"];
415-
e2 -> e3 [style=dashed];
416-
e3 [color=invis label="optional"
417-
tooltip="Optional/**kw/*vararg `needs`."
418-
URL="arch.html#term-needs"];
419-
e3 -> e4 [color=blue];
420-
e4 [color=invis label="sideffect"
421-
tooltip="Fictive data not consumed/produced by underlying function."
422-
URL="arch.html#term-sideffects"];
423-
e4 -> e5 [color="#009999" penwidth=4 style=dotted arrowhead=vee label=1 fontcolor="#009999"];
424-
e5 [color=invis penwidth=4 label="execution sequence"
425-
tooltip="Sequence of execution steps."
426-
URL="arch.html#term-execution-steps"];
424+
tooltip="Data contained in the solution."
425+
URL="%(url)s#term-solution"];
426+
overwrite [shape=rect style=filled fillcolor=SkyBlue
427+
tooltip="More than 1 values exist in solution with this name."
428+
URL="%(url)s#term-overwrites"];
429+
data -> input -> output -> inp_out -> evicted -> sol -> overwrite [style=invis];
430+
431+
e1 [style=invis];
432+
e1 -> requirement;
433+
requirement [color=invis
434+
tooltip="From operation --> `provides`, or from `needs` --> operation."
435+
URL="%(url)s#term-needs"];
436+
requirement -> optional [style=dashed];
437+
optional [color=invis
438+
tooltip="The operation can run even if this `need` is missing (e.g. *varag, **kw)."
439+
URL="%(url)s#term-needs"];
440+
optional -> sideffect [color=blue];
441+
sideffect [color=invis
442+
tooltip="Fictive data not consumed/produced by underlying function."
443+
URL="%(url)s#term-sideffects"];
444+
sideffect -> sequence [color="#009999" penwidth=4 style=dotted
445+
arrowhead=vee label=1 fontcolor="#009999"];
446+
sequence [color=invis penwidth=4 label="execution sequence"
447+
tooltip="Sequence of execution steps."
448+
URL="%(url)s#term-execution-steps"];
427449
}
428450
}
429-
"""
451+
""" % {
452+
"url": arch_url
453+
}
430454

431455
dot = pydot.graph_from_dot_data(dot_text)[0]
432456
# clus = pydot.Cluster("Graphtik legend", label="Graphtik legend")

0 commit comments

Comments
 (0)