First, I defined a line through matplotlib.lines.Line2D
:
import matplotlib.lines as mlines
newLine = mlines.Line2D([], [], color="blue", linestyle='-',linewidth=2)
(For simplicity) In the same script file, I would like to call these line settings whenever possible through: matplotlib.pyplot.plot
without repeating the kwargs, such as:
import matplotlib.pyplot as plt
import numpy as np
dataXaxis=np.arange(0,10)
dataYaxis=np.arange(5,15)
plt.plot(dataXaxis, dataYaxis, <CALL newLine PROPERTIES>)
instead of:
plt.plot(dataXaxis, dataYaxis, color="blue", linestyle='-',linewidth=2)
Context:
I might be confused with the above functionalities. Yet I want to use predefined line style settings associated to a predefined concept. For instance, I want to use a particular line style whenever I plot 'input vs. time' relation, and another particular style to plot 'output vs. time' relation.
You could just define a dictionary with the keyword arguments that you want to use each time, e.g.,
newlinestyle = {'color': 'blue', 'linestyle': '-', 'linewidth': 2}
plt.plot(dataXaxis, dataYaxis, **newlinestyle)