Допустим, я хочу построить другой атрибут объектов класса из функции.
Пока у меня есть это:
...
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()
, где deviceList - это список, содержащий экземпляры класса с различными атрибутами, такими как Например, u
, z
или T
.
Теперь, когда я вызываю функцию, я объявляю xVars, yVars, xLims, yLims как массивы строк, что, очевидно, не работает , Но я не знаю, как это назвать. И я даже не знаю, как это искать в руководствах ...
plot2vars (
deviceList,
xVars=['u', 'u'], yVars=['z', 'T'],
xLims=['', 'left=0.8'], yLims=['','bottom=0, top=0.8']
)