String representation of a matplotlib figure for doctrines

I am writing doctests for my code that generates a matplotlib shape, I was wondering if there is a way to print the shape in a line representation - something that displays the elements in the drawing (lines, dots, etc.). For example, something like the following:

>>> plt.plot([1,2,3], label="line 1")
>>> plt.plot([3,2,1], label="line 2")
>>> fig = plt.gcf()
>>> print fig
<Figure>
    <Line label='line 1'>
    <Line label='line 2'>
+4
source share

Source: https://habr.com/ru/post/1626962/


All Articles