Closed Mingzefei closed 10 months ago
I googled and found that this code can be used to achieve the above purpose.
plt.plot(x1, y1, 'o', label='data 1')
plt.plot(x2, y2, 'o', label='data 2')
plt.plot(x1, np.polyval(y1_fit, x1), '--', label='fit 1', color=plt.gca().lines[0].get_color()) # Set the color to match the first data
plt.plot(x2, np.polyval(y2_fit, x2), '--', label='fit 2', color=plt.gca().lines[1].get_color()) # Set the color to match the second
But this code is too bloated. Is there a better way?
You can use the color
parameter passed to plt.plot
with:
E.g.: plt.plot(x, y, color='purple')
This parameter changes the color applied to whatever is plotted with that plt.plot
.
Hope to have helped you. I'll close this issue since this is not related to SciencePlots.
Environment
Describe your issue here
plot
commands. Looking forward to your help and thank you for implementing a great tool.How can we reproduce it? What have you tried?
Extra info
No response