seaborn

Confidence Interval for a Seaborn Boxplot

这一生的挚爱 提交于 2019-12-25 10:06:05
问题 I see that I can set a specific confidence interval on a seaboard point plot https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.pointplot.html however, for the 'notch' attribute on the seaboard box plot there seems to be no flexibility for the user to Specify the CI. Is there a way to do this? What is the confidence level of the default seaborn box plot notch? 回答1: seaborn relies on boxplot provided by matplotlib - see docs. The default is 95%, but here's an example how to

Using seaborn heatmap

强颜欢笑 提交于 2019-12-25 09:27:58
问题 I am running into some issues using heatmap in seaborn Code: df[['latitude', 'longitude', 'interest_level']] a = df.pivot('latitude', 'longitude', 'interest_level') Error: ValueError: Index contains duplicate entries, cannot reshape Interest level has multiple duplicate values. What i am envisioning is that the lat/long would form a 2D diagram, with the interest level being the value in the map. Interest level is categorical with only 3 unique values. Am i using the wrong class as i am

How to draw a heatmap in pandas with items that don't occur in both columns

試著忘記壹切 提交于 2019-12-25 09:12:30
问题 In How to draw a graphical count table in pandas I asked how to draw a heatmap from input data such as: customer1,customer2 a,b a,c a,c b,a b,c b,c c,c a,a b,c b,c The answer was x = df.pivot_table(index='customer1',columns='customer2',aggfunc='size',fill_value=0) idx = x.max(axis=1).sort_values(ascending=0).index sns.heatmap(x[idx].reindex(idx), annot=True) This gives a square matrix showing the number of counts for each pair from the two columns. This solution doesn't work however if there

Patches in seaborn

眉间皱痕 提交于 2019-12-25 07:59:18
问题 My intention is to add a patch at a specific coordinate in seaborn's lmplot : Is there anyway to add a rectangular/square patch to lmplot ? I was able to get the plot printed out through sns.lmplot() . But when I try to add the rectangular patch using ax.add_patch() statement with relevant coordinate's, it error's out. #Sample code to generate lmplot and add patch ax= sns.lmplot('A', 'B', hue="group", data=res_me,fit_reg=False, \ palette="Set1",size=10, aspect=1, scatter_kws={"s": 100,

Seaborn visualize groups

[亡魂溺海] 提交于 2019-12-25 07:59:17
问题 How can I plot this data frame using seaborn to show the KPI per model? allFrame = pd.DataFrame({'modelName':['first','second', 'third'], 'kpi_1':[1,2,3], 'kpi_2':[2,4,3]}) Not like sns.barplot(x="kpi2", y="kpi1", hue="modelName", data=allFrame) But rather like this per KPI 回答1: Try melt ing the dataframe first, and then you can plot using seaborn : import pandas as pd import seaborn as sns allFrame = pd.DataFrame({'modelName':['first','second', 'third'], 'kpi_1':[1,2,3], 'kpi_2':[2,4,3]})

Combining FacetGrid and dual Y-axis in Pandas

浪尽此生 提交于 2019-12-25 07:51:28
问题 I am trying to plot two different variables (linked by a relation of causality), delai_jour and date_sondage on a single FacetGrid. I can do it with this code: g = sns.FacetGrid(df_verif_sum, col="prefecture", col_wrap=2, aspect=2, sharex=True,) g = g.map(plt.plot, "date_sondage", "delai_jour", color="m", linewidth=2) g = g.map(plt.bar, "date_sondage", "impossible") which gives me this: FacetGrid (There are 33 of them in total). I'm interested in comparing the patterns across the various

Plots do not appear when calling seaborn's pairplot on a pandas Dataframe

会有一股神秘感。 提交于 2019-12-25 02:28:06
问题 I have a Dataframe that looks like so Price Mileage Age 4250 71000 8 6500 43100 6 26950 10000 3 1295 78000 17 5999 61600 8 This is assigned to dataset . I simply call sns.pairplot(dataset) and I'm left with just a single graph - the distribution of prices across my dataset. I expected a 3x3 grid of plots. When I import a pre-configured dataset from seaborn I get the expected multiplot pair plot. I'm new to seaborn so apologies if this is a silly question, but what am I doing wrong? It seems

Ordering a python Seaborn bar-plot by ascending or descending?

血红的双手。 提交于 2019-12-25 01:49:01
问题 This is my current code using a dataset of causes of death within the united states by number of occurrences: `top_cause_of_death_barplot=sns.catplot(data=death, x='cause_name', y='deaths',kind='bar',ci=None,legend_out=False,height=10, aspect=1.5) plt.xlabel('Causes of Death',fontsize=15) top_cause_of_death_barplot.set_xticklabels(fontsize=10) plt.ylabel('Number of Observed Deaths',fontsize=15) plt.title('Top Ten Leading Causes of Death in the United States (1999-2017)',fontsize=20)` This

How to add a legend to scatterplot

此生再无相见时 提交于 2019-12-25 00:21:46
问题 I am doing an exercise for a Machine Learning course. I appended to a matrix a dataset of images in form of arrays into datamatrix, then I standardized it and then computed the principal components. Labels is an array containing for each image the label (that was the subdirectory containing it) I need to visualize pairs of principal components, in this part the first two. The suggestion from the professor was to use the matplotli.scatter function, I found the seaborn.scatterplot function that

Showing seaborn plot from dictionary

我们两清 提交于 2019-12-25 00:07:48
问题 I need to store plots in a dictionary like this: import matplotlib.pyplot as plt import seaborn as sns test = dict() test['a'] = sns.lmplot(x="sepal_length", y="sepal_width", hue="species", truncate=True, height=5, data=sns.load_dataset("iris")) But how do I show that plot from the dict ? test['a'] returns the plot object like <seaborn.axisgrid.FacetGrid at 0x233011bfe80> but does not show the plot itself. test['a'] plt.show() Does not show the plot either. Any suggestions how to show the