-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Milestone
Description
I was trying to use seaborn kdeplot with custom colour ramp, it is working with seaboarn version 0.11.00, but not with seaboarn 0.12.0
color ramp as below
def make_Ramp( ramp_colors ):
from colour import Color
from matplotlib.colors import LinearSegmentedColormap
color_ramp = LinearSegmentedColormap.from_list( 'my_list', [ Color( c1 ).rgb for c1 in ramp_colors ] )
plt.figure( figsize = (15,3))
plt.imshow( [list(np.arange(0, len( ramp_colors ) , 0.1)) ] , interpolation='nearest', origin='lower', cmap= color_ramp )
plt.xticks([])
plt.yticks([])
return color_ramp
custom_ramp = make_Ramp( ['#0000ff','#00ffff','#ffff00','#ff0000' ] )
my data look like this
0 1 2
0 142.5705 38.5744 hairpins
1 281.0795 55.1900 hairpins
2 101.7282 49.5604 hairpins
3 59.8472 63.0699 hairpins
4 296.4381 44.8293 hairpins
.. ... ... ...
347 284.6841 51.7468 stems
348 288.7241 49.9322 stems
349 320.2972 41.5520 stems
350 302.6805 67.2658 stems
351 293.6837 52.0663 stems
[352 rows x 3 columns]
<class 'numpy.float64'>
this is my code
ax = sns.kdeplot(data=df, x=df.loc[df[2] == "hairpins", 0], y=df.loc[df[2] == "hairpins", 1], fill=False, thresh=0, levels=20, cmap=custom_ramp, common_norm=True, cbar=True, )
with version 0.12.0 get this error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-6-88652c0ba7ce>](https://localhost:8080/#) in <module>
21 #/
22 plt.subplot(2,3,i+1)
---> 23 ax = sns.kdeplot(data=df, x=df.loc[df[2] == dimtypes[i], 0], y=df.loc[df[2] == dimtypes[i], 1], fill=False, thresh=0, levels=20, cmap=custom_ramp, common_norm=True, cbar=True, cbar_kws={'format': '%2.1e', 'label': 'kernel density'} )
24 plt.title("Chart {}: {}".format(i+1, dimtypes[i]), size=20)
25 plt.xlabel(str(xname), fontsize=12)
9 frames
[/usr/local/lib/python3.7/dist-packages/matplotlib/artist.py](https://localhost:8080/#) in update(self, props)
1065 func = getattr(self, f"set_{k}", None)
1066 if not callable(func):
-> 1067 raise AttributeError(f"{type(self).__name__!r} object "
1068 f"has no property {k!r}")
1069 ret.append(func(v))
AttributeError: 'Line2D' object has no property 'cmap'
with version 0.11.0 get this plot
basically, custom ramp is not woking with seaborn 0.12.0 , please update thanks