'Is it possible to get the json value of a matplotlib object?
I'm working on code generation with deep learning. I have a code (the ground truth) using matplotlib to plot a figure. My trained neural network will generate too a code to plot the figure. I would like to compare automatically both plot (it is not clever to compare the code because two different codes could return the same result).
I could compare both images but it is not convenient, is it possible to compare two plot objects with a boolean response?
For example, i have the following ground truth:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
fig, ax = plt.subplots()
for i in range(1, 6):
ax.plot(x, i*x + x, label='$y={i}x + {i}$'.format(i=i))
ax.legend(loc='upper left')
plt.show()
And this generated code:
import matplotlib.pyplot as plt1
import numpy as np
x = np.linspace(0, 10, 100)
fig, ax = plt1.subplots()
ax.legend(loc='upper left')
for i in range(1, 6):
ax.plot(x, i*x + x, label='$y={i}x + {i}$'.format(i=i))
plt1.show()
Both code give the same plot with one swapping line, i would like to test something like:
plt == plt1
>> True
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
