I'm a relative new comer to Python (but am experienced in many other languages!) and am writing a Python script to process scientific measurement data.
I've ended up with a number of class functions that each call matplotlib.pyplot.plot(). I include a simple example below:
def plot_measurement(self, x, x_label, y, y_label, plot_label = "", format = "-b", line_width = 1, latex_mode = False):
if (plot_label == ""):
plot_label = self.identifier
if (latex_mode):
matplotlib.rc("text", usetex = True)
matplotlib.rc("font", family = "serif")
matplotlib.pyplot.plot(x, y, format, linewidth = line_width, label = plot_label)
matplotlib.pyplot.xlabel(x_label)
matplotlib.pyplot.ylabel(y_label)
I would like to be able to add all of the matplotlib.pyplot.plot() parameters to my new functions so that I may feed them into matplotlib.pyplot.plot() but don't wish to do so manually (by adding them to the function declaration), which you'll see from that code snippet that I have already done so in some cases. The crux is that each new function has it's own set of parameters that somehow need to be distinguished from the parameters to matplotlib.pyplot.plot().
A little bit of searching online led me to discovering Python decorators but I have not been able to find a good example that will help me in this instance. I'm convinced there is an easy way to do this in Python.
If someone could please help me with this I would be most grateful.