當前位置: 首頁>>代碼示例>>Python>>正文


Python seaborn.hls_palette方法代碼示例

本文整理匯總了Python中seaborn.hls_palette方法的典型用法代碼示例。如果您正苦於以下問題:Python seaborn.hls_palette方法的具體用法?Python seaborn.hls_palette怎麽用?Python seaborn.hls_palette使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在seaborn的用法示例。


在下文中一共展示了seaborn.hls_palette方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_labs_to_cmap

# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import hls_palette [as 別名]
def test_labs_to_cmap():
    sids = [0, 1, 2, 3, 4, 5, 6, 7]
    labs = list(map(str, [3, 0, 1, 0, 0, 1, 2, 2]))
    slab_csamples = eda.SingleLabelClassifiedSamples(
        np.random.ranf(80).reshape(8, -1), labs, sids)

    (lab_cmap, lab_norm, lab_ind_arr, lab_col_lut,
     uniq_lab_lut) = eda.plot.labs_to_cmap(slab_csamples.labs, return_lut=True)

    n_uniq_labs = len(set(labs))
    assert lab_cmap.N == n_uniq_labs
    assert lab_cmap.colors == sns.hls_palette(n_uniq_labs)
    np.testing.assert_equal(
        lab_ind_arr, np.array([3, 0, 1, 0, 0, 1, 2, 2]))
    assert labs == [uniq_lab_lut[x] for x in lab_ind_arr]
    assert len(uniq_lab_lut) == n_uniq_labs
    assert len(lab_col_lut) == n_uniq_labs
    assert [lab_col_lut[uniq_lab_lut[i]]
            for i in range(n_uniq_labs)] == sns.hls_palette(n_uniq_labs)

    lab_cmap2, lab_norm2 = eda.plot.labs_to_cmap(
        slab_csamples.labs, return_lut=False)
    assert lab_cmap2.N == n_uniq_labs
    assert lab_cmap2.colors == lab_cmap.colors
    np.testing.assert_equal(lab_norm2.boundaries, lab_norm.boundaries) 
開發者ID:TaylorResearchLab,項目名稱:scedar,代碼行數:27,代碼來源:test_plot.py

示例2: set_label_color

# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import hls_palette [as 別名]
def set_label_color(nb_colors):
    """Set a color for each aggregated label with seaborn palettes

    Parameters
    ----------
    nb_colors : int
        Number of label to display
    """
    palette = sns.hls_palette(nb_colors, 0.01, 0.6, 0.75)
    return ([int(255 * item) for item in color] for color in palette) 
開發者ID:Oslandia,項目名稱:deeposlandia,代碼行數:12,代碼來源:aggregate_label.py

示例3: visualize_hist_pairplot

# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import hls_palette [as 別名]
def visualize_hist_pairplot(X,y,selected_feature1,selected_feature2,features,diag_kind):
	"""
	Visualize the pairwise relationships (Histograms and Density Funcions) between classes and respective attributes

	Keyword arguments:
	X -- The feature vectors
	y -- The target vector
	selected_feature1 - First feature
	selected_feature1 - Second feature
	diag_kind -- Type of plot in the diagonal (Histogram or Density Function)
	"""

	#create data
	joint_data=np.column_stack((X,y))
	column_names=features

	#create dataframe
	df=pd.DataFrame(data=joint_data,columns=column_names)

	#plot
	palette = sea.hls_palette()
	splot=sea.pairplot(df, hue="Y", palette={0:palette[2],1:palette[0]},vars=[selected_feature1,selected_feature2],diag_kind=diag_kind)
	splot.fig.suptitle('Pairwise relationship: '+selected_feature1+" vs "+selected_feature2)
	splot.set(xticklabels=[])
	# plt.subplots_adjust(right=0.94, top=0.94)

	#save fig
	output_dir = "img"
	save_fig(output_dir,'{}/{}_{}_hist_pairplot.png'.format(output_dir,selected_feature1,selected_feature2))
	# plt.show() 
開發者ID:alexpnt,項目名稱:default-credit-card-prediction,代碼行數:32,代碼來源:visualization.py

示例4: visualize_feature_boxplot

# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import hls_palette [as 別名]
def visualize_feature_boxplot(X,y,selected_feature,features):
	"""
	Visualize the boxplot of a feature

	Keyword arguments:
	X -- The feature vectors
	y -- The target vector
	selected_feature -- The desired feature to obtain the histogram
	features -- Vector of feature names (X1 to XN)
	"""

	#create data
	joint_data=np.column_stack((X,y))
	column_names=features

	#create dataframe
	df=pd.DataFrame(data=joint_data,columns=column_names)

	# palette = sea.hls_palette()
	splot=sea.boxplot(data=df,x='Y',y=selected_feature,hue="Y",palette="husl")
	plt.title('BoxPlot Distribution of '+selected_feature)

	#save fig
	output_dir = "img"
	save_fig(output_dir,'{}/{}_boxplot.png'.format(output_dir,selected_feature))
	# plt.show() 
開發者ID:alexpnt,項目名稱:default-credit-card-prediction,代碼行數:28,代碼來源:visualization.py

示例5: labs_to_cmap

# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import hls_palette [as 別名]
def labs_to_cmap(labels, return_lut=False, shuffle_colors=False,
                 random_state=None):
    np.random.seed(random_state)
    # Each label has its own index and color
    mtype.check_is_valid_labs(labels)

    labels = np.array(labels)
    uniq_lab_arr = np.unique(labels)
    num_uniq_labs = len(uniq_lab_arr)
    uniq_lab_inds = list(range(num_uniq_labs))

    lab_col_list = list(sns.hls_palette(num_uniq_labs))
    if shuffle_colors:
        np.random.shuffle(lab_col_list)

    lab_cmap = mpl.colors.ListedColormap(lab_col_list)
    # Need to keep track the order of unique labels, so that a labeled
    # legend can be generated.
    # Map unique label indices to unique labels
    uniq_lab_lut = dict(zip(range(num_uniq_labs), uniq_lab_arr))
    # Map unique labels to indices
    uniq_ind_lut = dict(zip(uniq_lab_arr, range(num_uniq_labs)))
    # a list of label indices
    lab_ind_arr = np.array([uniq_ind_lut[x] for x in labels])

    # map unique labels to colors
    # Used to generate legends
    lab_col_lut = dict(zip([uniq_lab_lut[i]
                            for i in range(len(uniq_lab_arr))],
                           lab_col_list))
    # norm separates cmap to difference indices
    # https://matplotlib.org/tutorials/colors/colorbar_only.html
    lab_norm = mpl.colors.BoundaryNorm(uniq_lab_inds + [lab_cmap.N],
                                       lab_cmap.N)
    if return_lut:
        return lab_cmap, lab_norm, lab_ind_arr, lab_col_lut, uniq_lab_lut
    else:
        return lab_cmap, lab_norm 
開發者ID:TaylorResearchLab,項目名稱:scedar,代碼行數:40,代碼來源:plot.py

示例6: DrawScatters

# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import hls_palette [as 別名]
def DrawScatters(savefolder, annoFile, visMethod, cords, annos):
    import plotly
    import plotly.graph_objs as go
    annText = os.path.basename(annoFile).split('.')[0]
        
    for kind in ['cell type', 'top sample']:
        if kind not in annos.columns:
            continue
        annotationList = sorted(list(set(annos.ix[:,kind])))
        
        import seaborn as sns 
        colorList = sns.hls_palette(n_colors=len(annotationList))
        
        data = []
        annoLen = 0
        for annoIdx in range(len(annotationList)):
            annoNames = annotationList[annoIdx]
            if len(annoNames) > annoLen:
                annoLen = len(annoNames)
            indicesOfAnno = annos[kind]==annoNames
            text = []
            for idx in annos.index[indicesOfAnno]:
                show_text = '%s: %s, barcode: %s' % (kind, annoNames, idx)
                text.append(show_text)
            trace = go.Scatter(
                x = cords.ix[annos.index[indicesOfAnno],'x'],
                y = cords.ix[annos.index[indicesOfAnno],'y'],
                name = annoNames,
                mode = 'markers',
                marker=dict(
                    color='rgb(%s, %s, %s)' % colorList[annoIdx],
                    size=5,
                    symbol='circle',
                    line=dict(
                        color='rgb(204, 204, 204)',
                        width=1
                    ),
                    opacity=0.9
                ),
                text = text,
             )
            data.append(trace)
        if annoLen < 35:
            layout = go.Layout(legend=dict(orientation="v"),autosize=True,showlegend=True)
        else:
            layout = go.Layout(legend=dict(orientation="v"),autosize=True,showlegend=False)
        fig = go.Figure(data=data, layout=layout)
        fn = os.path.join(savefolder, '%s_%s_%s.html' % (annText, kind.replace(' ', '_'), visMethod))
        print('##########saving plot: %s' % fn)
        plotly.offline.plot(fig, filename=fn)

#start to visualise test dataset 
開發者ID:asrhou,項目名稱:scMatch,代碼行數:54,代碼來源:visAnnos.py


注:本文中的seaborn.hls_palette方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。