I already checked out this question, but it didn't solve my problem.
Hello! I have a pyplot figure:
def foo(data): fig, ax = plt. subplots(figsize=(20, 10), dpi=100)
xaxis = (list with x values)
yaxis = (numpy array with y values)
ax.plot(xaxis, yaxis)
I would like foo() to return the x and y values. I understand that I could just do
return xvalues, yvalues
But I'd like to extract the data from the figure.
I've tried my best to read the pyplot documentation, but I'm still pretty new to it, so if I'm doing something stupid, please let me know!
EDIT: I wasn't really descriptive enough, sorry. I'm trying to write a unit test for a module where one of the methods is to generate and save a graph. foo() doesn't necessarily have to return the x and y data, I'd just like it to return something I can use to make sure it generated the plot properly. I'm aware that matplotlib has testing stuff built in, but I would have to restructure a lot of my code to make it work.