There are quite a few options you can use dictionaries or as you said construct your own classes. If you are migrating from matlab also consider the numpy module since it makes operating arrays (or matrix) a breeze. Below is a short example of how to use them.
import numpy as np
import matplotlib.pyplot as plt
time = np.linspace(0.0, 10.0, 51)
current = np.random.randint(115,125,size=(51))
voltage = current*(time**2)
#Dictionary Example
model_dict = {'time': time, 'voltage': voltage, 'current': current}
plt_attr = {'color': ['r','b','g','k']}
fig, ax1 = plt.subplots(2,1)
ax1[0].title.set_text('Dictionary Example')
ax1[0].set_xlabel('time (s)')
ax1[0].set_ylabel('Voltage [V]', color=plt_attr['color'][0])
# Note how the variables are called
ax1[0].plot(model_dict['time'], model_dict['voltage'], color=plt_attr['color'][0])
ax1[0].tick_params(axis='y', labelcolor=plt_attr['color'][0])
ax2 = ax1[0].twinx() # instantiate a second axes that shares the same x-axis
ax2.set_ylabel('Current [Amp]', color=plt_attr['color'][1]) # we already handled the x-label with ax1
# Note how the variables are called
ax2.plot(model_dict['time'], model_dict['current'], color=plt_attr['color'][1])
ax2.tick_params(axis='y', labelcolor=plt_attr['color'][1])
#Class Example
class model:
def __init__(self, name, i = None, v = None, e = None, t = None):
self.name = name
self.current = i
self.voltage = v
self.energy = e
self.time = t
model_class = model('model_1', i = current, v = voltage, t = time)
ax1[1].title.set_text('Class Example')
ax1[1].set_xlabel('time (s)')
ax1[1].set_ylabel('Voltage [V]', color=plt_attr['color'][2])
# Note how the variables are called
ax1[1].plot(model_class.time, model_class.voltage, color=plt_attr['color'][2])
ax1[1].tick_params(axis='y', labelcolor=plt_attr['color'][2])
ax2 = ax1[1].twinx() # instantiate a second axes that shares the same x-axis
ax2.set_ylabel('Current [Amp]', color=plt_attr['color'][3]) # we already handled the x-label with ax1
# Note how the variables are called
ax2.plot(model_class.time, model_class.current, color=plt_attr['color'][3])
ax2.tick_params(axis='y', labelcolor=plt_attr['color'][3])
plt.show()