unable to plot with custom color ramp seaborn 0.12.0
See original GitHub issueI 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
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Choosing color palettes — seaborn 0.12.1 documentation
General principles for using color in plots#. Components of color#. Because of the way our eyes work, a particular color can be defined...
Read more >Plots fail when `axes.prop_cycle` rcparam cycler has no color
This is due to an old deprecation of axes.color_cycle rcparam, which get_color_cycle() uses when there's no color cycler available. Example code ...
Read more >Seaborn Color Palette not working appropiate with lineplot
I'm having a little trouble with customizing my colors for a lineplot. I want to show an ensemble of spectras with a sequential...
Read more >How to use your own color palettes with Seaborn
Using an existing color palette, the only thing you need to do is to set it before calling the plot methods, and any...
Read more >The Notebook | Query and analyze data - Mode Support
In each case, all query results are delivered to the Notebook as a custom object called datasets . datasets contains objects of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @y-h-wang, this is a perfect reprex and makes it much easier to debug. Indeed, this is a regression, not an intentional change. The root cause is https://github.com/mwaskom/seaborn/pull/2449.
Encountered the same issue. The following code shows a reproducible example that works with seaborn 0.11.0 while ends up with
AttributeError: 'Line2D' object has no property 'cmap'
with 0.12.0. I would assume this is not a desired feature since nothing related mentioned in the changelog.