Let's say I want to plot different class objects attribute from a function.
So far I have this:
...
import matplotlib.pyplot as plt
def plot2vars (deviceList, xVars, yVars, xLims, yLims, colormap=plt.cm.Spectral):
x0 = xVars[0]
x1 = xVars[1]
y0 = yVars[0]
y1 = yVars[1]
fig, ax = plt.subplots(1,2)
fig, ax = plt.subplots(1,2)
for d in deviceList: #these 'd' are the class instances...
if not d.discard:
ax[0].plot(d.x0, d.y0)
ax[0].set_xlim(xLims[0])
ax[0].set_ylim(yLims[0])
ax[1].plot(d.x1, d.y1)
ax[1].set_xlim(xLims[1])
ax[1].set_ylim(yLims[1])
plt.show()
where deviceList is a list containing class instances with different attributes like, for example, u, z or T.
Now, when I call the function, I declare xVars, yVars, xLims, yLims as arrays of strings, which obviously doesn't work. But I don't know how to call these. And I don't even know how to look for this in the manuals...
plot2vars (
deviceList,
xVars=['u', 'u'], yVars=['z', 'T'],
xLims=['', 'left=0.8'], yLims=['','bottom=0, top=0.8']
)
deviceList)xVarsandyVarsbut never uses them. Is it okay?x0, y0 ...fromxVarsandyVarsbut you don't use them below.d.x0, python complains there is not x0 attribute of the class, and of course there isn't. I want to calld.uinstead. And I want to be able to call different attributes everytime I call the function. That's why I need it to be a variable. But I don't know how to.