如何从使用Seaborn在python中创建的直方图中删除透明度? [英] How do I remove transparency from a histogram created using Seaborn in python?

查看:45
本文介绍了如何从使用Seaborn在python中创建的直方图中删除透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用seaborn在python中创建直方图,并希望自定义颜色.默认设置会创建透明的直方图,我希望我能保持稳定.如何删除透明度?

I'm creating histograms using seaborn in python and want to customize the colors. The default settings create transparent histograms, and I would like mine to be solid. How do I remove the transparency?

我尝试创建调色板并将去饱和度设置为0,但这并没有改变结果直方图的饱和度.

I've tried creating a color palette and setting desaturation to 0, but this hasn't changed the saturation of the resulting histogram.

示例:

# In[1]:

import seaborn as sns
import matplotlib.pyplot as plt
get_ipython().magic('matplotlib inline')


# In[2]:

iris = sns.load_dataset("iris")


# In[3]:

myColors = ['#115e67','#f4633a','#ffd757','#4da2e8','#cfe5e5']
sns.palplot(sns.color_palette(myColors))


# In[4]:

sns.set_palette(palette=myColors,desat=0)


# In[5]:

sns.set(style="white")


# In[6]:

sns.despine()


# In[7]:

plt.title('Distribution of Petal Length')
sns.distplot(iris.petal_length, axlabel = 'Petal Length')

花瓣长度的分布

推荐答案

sns.distplot(iris.petal_length, axlabel = 'Petal Length', hist_kws=dict(alpha=1))

这篇关于如何从使用Seaborn在python中创建的直方图中删除透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆