seaborn

Can I retrieve the bandwidth used in a seaborn kdeplot?

為{幸葍}努か 提交于 2021-02-11 16:50:25
问题 I am using sns.kdeplot(data) to obtain a Kernel Density Estimate for my 1 dimensional dataset. As I understand and having read seaborn's documentation on kdeplot, sns.kdeplot() passes bw_method="Scott" to scipy.stats.gaussian_kde to automatically obtain a rule-based bandwidth to smoothening the kde plot in question. Can I access the bandwidth that was automatically used by seaborn for its kdeplot? My idea was to reproduce seaborn's steps through scipy.stats.gaussian_kde and applying the rule

how to plot categorical and continuous data in pandas/matplotlib/seaborn

一曲冷凌霜 提交于 2021-02-11 14:56:27
问题 I am trying to figure out how could I plot this data: column 1 ['genres']: These are the value counts for all the genres in the table Drama 2453 Comedy 2319 Action 1590 Horror 915 Adventure 586 Thriller 491 Documentary 432 Animation 403 Crime 380 Fantasy 272 Science Fiction 214 Romance 186 Family 144 Mystery 125 Music 100 TV Movie 78 War 59 History 44 Western 42 Foreign 9 Name: genres, dtype: int64 column 2 ['release_year']: These are the value counts for all the release years for different

How to display ticks in plain number for seaborn heatmap with logarithmic scale?

被刻印的时光 ゝ 提交于 2021-02-11 14:41:20
问题 I am generating a heatmap using seaborn which has a logarithmic scale. How can I change the colorbar labels from scientific notation to plain number. import math from matplotlib.colors import LogNorm vmax=2 vmin=0.5 center = (vmax+vmin)/2 log_norm = LogNorm(vmin=vmin, vmax=vmin) cbar_ticks = [0.5, 0.66, 1, 1.5, 2] ax = sns.heatmap(corr, square=True, mask=mask, cmap=cmap_type, linewidths=.5, vmax=vmax, vmin=vmin, norm=log_norm, cbar_kws={"ticks": cbar_ticks}, center=center) Edit: The following

How to make items clickable (onpick) in Seaborn scatterplot?

不打扰是莪最后的温柔 提交于 2021-02-11 14:26:40
问题 I'm using sns.scatterplot function to analyze some data. It would be very helpful for me if I could pick an object on the plot by clicking on it and execute a function. Matplotlib has onpick event which does the trick, but I couldn't find how could I do the same with Seaborn. It is using Matplotlib internally, so I think that it is possible somehow to attach onpick handler to it. The reason I'm using Seaborn instead of basic Matplotlib plot is that I need hue parameter. Here is basically the

Relabel axis ticks in seaborn heatmap

流过昼夜 提交于 2021-02-11 13:33:00
问题 I have a seaborn heatmap that I am building from a matrix of values. Each element of the matrix corresponds to an entitiy that I would like to make the tick label for each row/col in the matrix. I tried using the ax.set_xticklabel() function to accomplish this but it seems to do nothing. Here is my code: type(jr_matrix) >>> numpy.ndarray jr_matrix.shape >>> (15, 15) short_cols = ['label1','label2',...,'label15'] # list of strings with len 15 fig, ax = plt.subplots(figsize=(13,10)) ax.set

Seaborn : linear regression on top of a boxplot

自作多情 提交于 2021-02-11 08:46:19
问题 With seaborn, how I can use sns.boxplot and sns.lmplot to obtain a boxplot with a regression line from the same data ? This does not work : tips = sns.load_dataset("tips") ax = sns.boxplot(x="size", y="tip", data=df) ax = sns.lmplot(x="size", y="tip", data=tips, x_estimator=np.mean); 回答1: You could try the following: tips = sns.load_dataset("tips") ax = sns.boxplot(x="size", y="tip", data=df) ax = sns.regplot(x="size", y="tip", data=tips); plt.show() Instead of using lmplot you can use

How can I label the clusters in sns clustermap

旧时模样 提交于 2021-02-11 06:01:17
问题 I am creating a clustermap with the following code. import numpy as np import pandas as pd import seaborn as sns all_net_names = ['early_vis', 'face', 'motion', 'scene', 'scene', 'scene', 'dmn', 'dmn', 'dmn', 'dmn', 'dmn', 'dmn', 'reward', 'reward', 'reward', 'reward', 'reward', 'ofc', 'ofc', 'ofc', 'ofc'] roi_names = ['E', 'F', 'M', 'S1', 'S2', 'S3', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'R1', 'R2', 'R3', 'R4', 'R5','O1', 'O2', 'O3', 'O4'] n_roi = len(roi_names) M = np.random.rand(n_roi, n_roi

How can I label the clusters in sns clustermap

二次信任 提交于 2021-02-11 06:01:02
问题 I am creating a clustermap with the following code. import numpy as np import pandas as pd import seaborn as sns all_net_names = ['early_vis', 'face', 'motion', 'scene', 'scene', 'scene', 'dmn', 'dmn', 'dmn', 'dmn', 'dmn', 'dmn', 'reward', 'reward', 'reward', 'reward', 'reward', 'ofc', 'ofc', 'ofc', 'ofc'] roi_names = ['E', 'F', 'M', 'S1', 'S2', 'S3', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'R1', 'R2', 'R3', 'R4', 'R5','O1', 'O2', 'O3', 'O4'] n_roi = len(roi_names) M = np.random.rand(n_roi, n_roi

How to include multiple data columns in a seaborn barplot?

自闭症网瘾萝莉.ら 提交于 2021-02-10 22:19:35
问题 I have a dataframe that looks like this: I have used a barplot to represent the subscribers for each row. This is what I did: data = channels.sort_values('subscribers', ascending=False).head(5) chart = sns.barplot(x = 'name', y='subscribers',data=data) chart.set_xticklabels(chart.get_xticklabels(), rotation=90) for p in chart.patches: chart.annotate("{:,.2f}".format(p.get_height(), '.2f'), (p.get_x() + p.get_width() / 2., p.get_height()), ha = 'center', va = 'center', xytext = (0, 10),

How to include multiple data columns in a seaborn barplot?

你离开我真会死。 提交于 2021-02-10 22:17:01
问题 I have a dataframe that looks like this: I have used a barplot to represent the subscribers for each row. This is what I did: data = channels.sort_values('subscribers', ascending=False).head(5) chart = sns.barplot(x = 'name', y='subscribers',data=data) chart.set_xticklabels(chart.get_xticklabels(), rotation=90) for p in chart.patches: chart.annotate("{:,.2f}".format(p.get_height(), '.2f'), (p.get_x() + p.get_width() / 2., p.get_height()), ha = 'center', va = 'center', xytext = (0, 10),