Home > Enterprise >  How to fix seaborn kde error for geographic coordinates
How to fix seaborn kde error for geographic coordinates

Time:10-25

I have the following dataframe (2000 rows)

Latitude    Longitude
31.400091   -109.782830
31.400091   -108.782830
31.410091   -108.782830
31.405091   -109.782830
31.400091   -110.77830
31.460091   -12.782830
...            ...

I'm currently trying to represent it the point mass concentration with kde from seaborn package :

x = df['Longitude']
y = df['Latitude']

x = x.to_numpy()
y = y.to_numpy()

sns.kdeplot(x, y, zorder=0, n_levels=6, shade=True, 
    cbar=True, shade_lowest=False, cmap='viridis')

Which give me :

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [58], in <cell line: 1>()
----> 1 sns.kdeplot(x, y, zorder=0, n_levels=6, shade=True, 
      2     cbar=True, shade_lowest=False, cmap='viridis')

TypeError: kdeplot() takes from 0 to 1 positional arguments but 2 positional arguments (and 1 keyword-only argument) were given

I've tried with numpy array transformation and without it, same result.

My seaborn version : '0.12.0'

CodePudding user response:

Try this:

sns.kdeplot(x=x, y=y, zorder=0, n_levels=6, shade=True, 
    cbar=True, shade_lowest=False, cmap='viridis')
  • Related