python define style/vairable for line (but not for figure)

27 Views Asked by At

I very often plot two types of results - e.g. prediction vs measurement - into a figure for a document, where the look of the corresponding lines/scatters should be match each other in different plots, but at the beginning of the writing/plotting the final look is not decided. I would like to define a bunch of plot options for every such curve, to make it possible to replot them very efficiently.

For example a would like to define the styles like:

s_theory = [linestyle="--", color="grey", marker=None, label="simulation"]
s_measurement = [linestyle=":", color="black", marker="s", markersize="5",label="measurement"]

I would like to apply these magically on plt.plot():

plt.plot(xt,yt,**s_theory)
plt.plot(xm,ym,**s_measurement)

How can I do that? What is the magic word I did not found during my search for this task? I am pretty sure there is a very simple to do that.

1

There are 1 best solutions below

0
Horror Vacui On

Based on the comment of ImportanceOfBeingErnest:

style_sim  = {"linestyle":"--", "color":"grey", "marker":"None", "label":"simulation"}
style_meas = {"linestyle":":", "color":"black", "marker":"s", "markersize":5, "label":"measurement"}
plt.plot(xt,yt,**style_sim)
plt.plot(xm,ym,**style_meas)

If you find it useful, please vote up the comment of ImportanceOfBeingErnest!