如何从 python 中使用 Seaborn 创建的直方图中删除透明度?
How do I remove transparency from a histogram created using Seaborn in python?
我在 python 中使用 seaborn 创建直方图并想自定义颜色。默认设置创建透明的直方图,我希望我的直方图是实心的。如何去除透明度?
我试过创建一个调色板并将去饱和度设置为 0,但这并没有改变生成的直方图的饱和度。
示例:
# 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))
我在 python 中使用 seaborn 创建直方图并想自定义颜色。默认设置创建透明的直方图,我希望我的直方图是实心的。如何去除透明度?
我试过创建一个调色板并将去饱和度设置为 0,但这并没有改变生成的直方图的饱和度。
示例:
# 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))