0

I have 15 features in my data set which are time series. I want to plot it in a pairplot, and have the colours of the points be corresponding to a sequential colormap like so:

enter image description here

Early datapoints will then have a brighter blue-color than the old ones.

One of the columns in my dataframe is called index, and I tried using the hue='Indexparameter in the plotting function, without any luck.

import matplotlib.pyplot as plt
sns.set(style="ticks", color_codes=True,palette='Blues_d')

#norm = plt.Normalize(df.Index.min(), df.Index.max())
#sm = plt.cm.ScalarMappable(cmap="Reds", norm=norm)
#sm.set_array([])

ax= sns.pairplot(df,vars=['AvgPower','energy_mean',
 'ActPower','WindSpeed','NacelleDirection','AvgSpeed','rms','kurt','skewness','signal_mean','Power spectral entropy','B1','B2','B3','B4','B5'],
hue='Index') # I do not include 'Index' in the vars, so it isn't plotted.

ax.get_legend().remove()
ax.figure.colorbar(sm)

plt.show()

How can I get this to work?

meerkat
  • 932
  • 2
  • 14
  • 38
  • 1
    Welcome to Stack Overflow! Please take a moment to read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). You need to provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) that includes a toy dataset (refer to [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)) – Diziet Asahi Apr 06 '20 at 14:28
  • I added a column manually called Index... I will update the question with a minimal example so it is clearer. – meerkat Apr 06 '20 at 19:42
  • 1
    Try `sns.pairplot(df, vars=..., hue='Index', palette='Blues_d')` – JohanC Apr 06 '20 at 22:52
  • Worked like a charm! – meerkat Apr 08 '20 at 12:38

0 Answers0