-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Description
(Not exactly a) Problem
I like to plot several lines with the same color (...and different linestyle for example).
It is already quite easy to write
def plt_last_color() : return plt.gca().lines[-1].get_color()
plt.plot(x, y1)
plt.plot(x, y2, lw=3, alpha=0.5, ls='dotted', color=plt_last_color())
Proposition
Yet it would be more elegant to have this way :
plt.plot(x, y2, lw=3, alpha=0.5, ls='dotted', color='last')
This would especially allow to have the 'last' keyword in a dictionnary, for easier management of big plots :
kw_1st = {}
kw_2nd = {lw=3, alpha=0.5, ls='dotted', color='last'}
plt.plot(x, y1, **kw_1st)
plt.plot(x, y2, **kw_2nd)
Probably, there are questions to consider like in the case of multiple axes instances :
ax.plot(x, y2, lw=3, alpha=0.5, ls='dotted', color='last')
-> should the 'last' color be the last one plotted in the referenced ax
of the same line (I think yes) or the last plotted color in the global plt scope...