sns lineplot set color in python

To set the color of a line plot in Python using seaborn and matplotlib, you can use the lineplot function from seaborn and specify the desired color using the color parameter.

Here is an example of how to set the color of a line plot:

main.py
import seaborn as sns
import matplotlib.pyplot as plt

# Create some sample data
x = [1, 2, 3, 4, 5]
y = [10, 12, 15, 20, 25]

# Set the color of the line plot
sns.lineplot(x=x, y=y, color='red')

# Add labels and title
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.title('Line Plot')

# Display the plot
plt.show()
316 chars
18 lines

In the above example, we import the seaborn and matplotlib.pyplot libraries. Then, we create some sample data for the x and y values. We pass these data to the lineplot function and specify the desired color ('red') using the color parameter. Finally, we add labels and title to the plot and display it using plt.show().

You can replace the 'red' color with any other valid color in Python, such as 'blue', 'green', 'yellow', etc., or you can use hexadecimal color codes like '#FF0000' for red.

Remember to adjust the code according to your own data and preferences.

gistlibby LogSnag