I can't use dashed lines to draw 2 time series on seaborn

539 Views Asked by At

I face a strange problem with no answer found :

I want to represent this dataframe (which is a time series) :

ts_velo.head()

    type_velo   nombre
date        
2016-09-01  VAE     0.980769
2016-09-01  Vélos   11.865385
2016-10-01  VAE     0.826087
2016-10-01  Vélos   9.152174
2016-11-01  VAE     0.711538
(...)

I can draw this graph :

sns.lineplot(x=ts_velo.index, y='nombre', data=ts_velo, hue='type_velo')

But I don't achieve to use dashed lines instead of solid lines.

I tried several things I read on stackoverflow, for example :

sns.lineplot(x=ts_velo.index, y='nombre', data=ts_velo, 
                                    hue='type_velo', dashes=[(2, 2), (2, 2)])

sns.lineplot(x=ts_velo.index, y='nombre', data=ts_velo, 
                                    hue='type_velo', dashes=True)

sns.lineplot(x=ts_velo.index, y='nombre', data=ts_velo, 
                                    hue='type_velo', dashes='--')


sns.lineplot(x=ts_velo.index, y='nombre', data=ts_velo, 
                                    hue='type_velo', ls='--')

g = sns.lineplot(x=ts_velo.index, y='nombre', data=ts_velo, hue='type_velo')
g.lines[0].set_linestyle("--")

But nothing works.

An idea of why I get this problem ?

1

There are 1 best solutions below

0
Sinan Kurmus On BEST ANSWER

You need to use style for dashes.

sns.lineplot(x=ts_velo.index, 
             y='nombre', 
             data=ts_velo,
             hue='type_velo', 
             style='type_velo',
             dashes=[(2, 2), (2, 2)])