![](/img/trans.png)
[英]With seaborn.facetgrid, how do I specify the color of a mapped scatter plot to reflect the values of a column in the data frame?
[英]Seaborn: Specify an exact color
您可以為繪圖指定顏色,但Seaborn會在繪圖期間稍微將顏色靜音。 有沒有辦法關閉這種行為?
例:
import matplotlib
import seaborn as sns
import numpy as np
# Create some data
np.random.seed(0)
x = np.random.randn(100)
# Set the Seaborn style
sns.set_style('white')
# Specify a color for plotting
current_palette = matplotlib.colors.hex2color('#86b92e')
# Make a plot
g = sns.distplot(x, color=current_palette)
# Show what the color should look like
sns.palplot(current_palette)
我已經嘗試了幾種方法來指定Seaborn中的顏色和所有可用的樣式,但沒有任何效果。 我正在使用iPython筆記本和Python 2.7。
它沒有使用柔和的顏色,它使用alpha /透明度值作為默認值的一部分。
兩個答案引用修改matplotlib對象透明度的方法:
seaborn.distplot
允許您傳遞不同的樣式參數( *_kws
)。 每個繪圖函數都有自己的參數,因此以圖的名稱為前綴。 例如。 直方圖有hist_kws
。 [ distplot參考 ]
因為直方圖是位於matplotlib中的,所以我們必須查看我們可以傳遞的關鍵字參數。 就像你已經想到的那樣,你可以傳遞'alpha'關鍵字參數來擺脫線條的透明度。 有關更多參數的參考信息(kwargs部分)。 [ pyplot參考 ]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.