I am trying to use decorators in my class to loop through my data and make plots with them. However, in my plotting function I import a method called "SplitLow" that takes in j as an argument, which is defined in my decorator. This obviously gives an error, since j is not defined in my plotting function. I tried to out "SplitLow" inside the decorator, but then it doesn't work for other inputs. Is there a way to implement a general function like "Splitlow" in the decorator to make this work? Thanks!
def gridfunc(self,PlotFunc):
"""
decorator that loops through length of self.Data to create j
plots It takes in a plotting functiong PlotFunc.
"""
def wrapper():
for j in range(len(self.Data)):
PlotFunc(Label = None, colors = None)
if j == range(len(self.Data)):
plt.xlabel("x")
plt.ylabel("y")
return wrapper
@gridfunc
def PlotTest(self, Label):
self.SplitLow(j) #Takes j as argument, defined in wrapper
plt.plot(self.xlow, self.ylow, label = Label)