The usual way to set the line color in matplotlib is to specify it in the plot command. This can be done as a string after the data, for example. "r-"for a red line or explicitly specifying an argument color.
import matplotlib.pyplot as plt
plt.plot([1,2,3], [2,3,1], "r-") # red line
plt.plot([1,2,3], [5,5,3], color="blue") # blue line
plt.show()
See also the documentation.
, lines2D.set_color().
line, = plt.plot([1,2,3], [4,5,3], color="blue")
line.set_color("black")
pandas :
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({ "x" : [1,2,3,5], "y" : [3,5,2,6]})
df.plot("x", "y", color="r")
plt.show()
,
plt.gca().get_lines()[0].set_color("black")
( ) .
,
for ax in plt.gcf().axes:
ax.get_lines()[0].set_color("black")
, .