MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / write_graphviz

Method write_graphviz

site-packages/matplotlib/transforms.py:192–241  ·  view source on GitHub ↗

For debugging purposes. Writes the transform tree rooted at 'self' to a graphviz "dot" format file. This file can be run through the "dot" utility to produce a graph of the transform tree. Affine transforms are marked in blue. Bounding

(self, fobj, highlight=[])

Source from the content-addressed store, hash-verified

190
191 if DEBUG:
192 def write_graphviz(self, fobj, highlight=[]):
193 """
194 For debugging purposes.
195
196 Writes the transform tree rooted at 'self' to a graphviz "dot"
197 format file. This file can be run through the "dot" utility
198 to produce a graph of the transform tree.
199
200 Affine transforms are marked in blue. Bounding boxes are
201 marked in yellow.
202
203 *fobj*: A Python file-like object
204
205 Once the "dot" file has been created, it can be turned into a
206 png easily with::
207
208 $> dot -Tpng -o $OUTPUT_FILE $DOT_FILE
209
210 """
211 seen = set()
212
213 def recurse(root):
214 if root in seen:
215 return
216 seen.add(root)
217 props = {}
218 label = root.__class__.__name__
219 if root._invalid:
220 label = '[%s]' % label
221 if root in highlight:
222 props['style'] = 'bold'
223 props['shape'] = 'box'
224 props['label'] = '"%s"' % label
225 props = ' '.join(map('{0[0]}={0[1]}'.format, props.items()))
226
227 fobj.write('%s [%s];\n' % (hash(root), props))
228
229 if hasattr(root, '_children'):
230 for child in root._children:
231 name = next((key for key, val in root.__dict__.items()
232 if val is child), '?')
233 fobj.write('"%s" -> "%s" [label="%s", fontsize=10];\n'
234 % (hash(root),
235 hash(child),
236 name))
237 recurse(child)
238
239 fobj.write("digraph G {\n")
240 recurse(self)
241 fobj.write("}\n")
242
243
244class BboxBase(TransformNode):

Callers

nothing calls this directly

Calls 2

recurseFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected