[英]How to reverse the palette of a seaborn scatterplot?
I am plotting a scatter plot of price of houses wrt latitude and longitude.我正在绘制房屋价格与纬度和经度的散点图。 I want to reverse the palette so that the red color depicts the most expensive house.我想反转调色板,以便红色描绘最昂贵的房子。
plt.figure(figsize=(12,8))
sns.scatterplot(x='long' ,y='lat' ,data=non_top_1_perc ,hue='price' ,edgecolor=None ,
alpha=0.2,palette='RdYlGn' )
Change your palette
parameter to this:将您的palette
参数更改为:
palette=plt.get_cmap('RdYlGn').reversed()
This is using matplotlibs
function named get_cmap
which has a reversed option made for this.这是使用名为get_cmap
matplotlibs
函数,它有一个相反的选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.