I am not sure if this thing has a name, so I couldn't find any information online so far, although surely there is!
Imagine my MWE:
def PlotElementsDict(dictionary1, dictionary2, itemToPlot, title):
# dictionary 1 and dictionary 2 are collections.OrderedDict with 'key':[1,2,3]
# i.e. there values of the keys are lists of numbers
list1 = [dictionary1[key][itemToPlot] for key in dictionary1.keys()]
list2 = [dictoinary2[key][itemToPlot] for key in dictionary2.keys()]
plt.plot(list1, label='l1, {}'.format(itemToPlot)
plt.plot(list2, label = 'l2, {}'.format(itemToPLot')
plt.legend()
plt.title(title)
return plt.show()
How can I create a function (but my question is even more general, I would like to be able to do this for a class as well) which takes a variable number of parameters of a certain type (for example n dictionaries) plus other parameters which you need only one? (for instance item to plot
or could be title
)?
In practice I would like to create a function (in my MWE) that no matter how many dictionaries I feed into the function, it manages to plot the given items of that dictionary given a common title and item to plot