How to set the x-label and y-label in a matplotlib-plot passing them as an parameter to the plot() function.
Basically I want to do something like this:
def plot_something(data, plot_conf):
data.plot(**plot_conf)
...do some other stuff...
plot_conf = {'title': 'Blabla', 'xlabel':'Time (s)', 'ylabel': 'Speed (m/s)'}
plot_something(data,plot_conf)
I would prefer not to use any additional function calls, like xlabel()
pyplot.plotfor valid kwargs. You can't pass xlabel, ylabel and title as arguments to theplot()method, as those are properties ofAxesinstances. Theplot()method returns aLine2Dinstance. IMO the easiest and most intuitive way to achieve this would be to change yourplot_something()function to actually use additional function calls.plot()method for eachAxesobject (e.g. plot two or more different lines in same subplot). If each of these method calls were to set the title, xlabel and ylabel of theAxes, everything would get pretty messy pretty fast! Also, this wouldn't be as intuitive and object-oriented as it currently is.