Reputation: 6280
I have a seaborn lineplot:
plt.figure(figsize=(22,14))
sns.lineplot(x="Datum", y="Value", ci=None, hue='Type', data=df)
plt.show()
Which leads to the following output:
How can i change the linecolors? For me the difference is hard to see.
Upvotes: 0
Views: 28717
Reputation: 91
At least in version 0.11.2 of seaborn, the lineplot function (http://seaborn.pydata.org/generated/seaborn.lineplot.html
) has a parameter called palette that allows changing the color map used for the hue.
To check the available color maps you can refer to https://matplotlib.org/stable/tutorials/colors/colormaps.html
import seaborn as sns
import matplotlib.pyplot as plt
fmri = sns.load_dataset("fmri")
#sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri, palette="tab10")
sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri, palette="Accent")
Upvotes: 3
Reputation: 195
You can change colors using palettes
. Referring to https://seaborn.pydata.org/tutorial/color_palettes.html, try:
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
fmri = sns.load_dataset("fmri")
# Try playing with one set or another:
#sns.set_palette("husl")
sns.set_palette("PuBuGn_d")
ax = sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri)
you'll get different line colors, like this
or this
Upvotes: 2
Reputation: 131
You can use colour inside lineplot() method, however this, far as I know, works only with Series. You can transform your data to Series with this this:
data = pd.Series(another_data)
Then plot Your data
sns.lineplot(..., data=data, color='red')
Another way is to use pallets
palette = sns.color_palette("mako_r", 6)
sns.lineplot(..., palette=palette, data=data)
More you can find in Seaborn lineplot reference: https://seaborn.pydata.org/generated/seaborn.lineplot.html Or here: https://stackoverflow.com/a/58432483/12366487
Upvotes: 3