'How to change the plot line color from blue to black?

I am stuck when I have generated a set of data and tried to color the plot line in python.

For example I would like to change the line color from blue to black here.

This is what I have and returns is the set of data that I got from pandas.

ax=plt.gca()
ax.set_axis_bgcolor('#cccccc')
returns.plot()

Screenshot of plot



Solution 1:[1]

If you get the object after creation (for instance after "seasonal_decompose"), you can always access and edit the properties of the plot; for instance, changing the color of the first subplot from blue to black:

plt.axes[0].get_lines()[0].set_color('black')

Solution 2:[2]

If you have more than one plot line and you want to set a different color for each line, use the attribute below in your plot() where each index represents a line color for a column.

color=['color1','color2']

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Florian Barras
Solution 2 sule mohammed