seaborn

Seaborn pairplot off-diagonal KDE with two classes

狂风中的少年 提交于 2020-06-10 09:03:22
问题 I'm trying to look at a Seaborn pairplot for two different classes of variables and I'd like to see KDEs on the offdiagonals instead of scatterplots. The documentation has instructions on how to do a KDE for all of the data, but I want to see separate KDEs for each subclass of data. Suggestions welcome! My code looks something like this: plot = sns.pairplot( df, vars=labels, hue='has_accident', palette='Set1', diag_kind='kde', ) which results in: As you can see the data are sufficiently dense

is seaborn confidence interval computed correctly?

别来无恙 提交于 2020-06-10 04:04:07
问题 First, I must admit that my statistics knowledge is rusty at best: even when it was shining new, it's not a discipline I particularly liked, which means I had a hard time making sense of it. Nevertheless, I took a look at how the barplot graphs were calculating error bars, and was surprised to find a "confidence interval" (CI) used instead of (the more common) standard deviation. Researching more CI led me to this wikipedia article which seems to say that, basically, a CI is computed as: Or,

Bar plot with groupby

主宰稳场 提交于 2020-06-10 02:33:08
问题 My categorical variable case_satus takes on four unique values. I have data from 2014 to 2016. I would like to plot the distribution of case_status grouped by year. I try to this using: df.groupby('year').case_status.value_counts().plot.barh() And I get the following plot: What I would like to have is a nicer represenation. For example where I have one color for each year, and all the "DENIED" would stand next to each other. I think it can be achieved since the groupby object is a multi-index

Seaborn swarmplot and pointplot dodge alignment

一世执手 提交于 2020-06-01 08:16:38
问题 I am plotting this: import seaborn as sns import numpy as np import pandas as pd import matplotlib.pyplot as plt fig, ax = plt.subplots(nrows=1, ncols=1) n=200 to_plot = np.random.uniform(low=0.0, high=1.0, size=n) mods = ['a','b'] model_col = mods*(n/2) opt=['1']*(n/2)+['2']*(n/2) d={'Model':pd.Series(model_col),'Par':pd.Series(to_plot),'opt':pd.Series(opt)} df = pd.DataFrame(d) sns.swarmplot(x='Model', y='Par',hue='opt',dodge=True,data=df,size=2,palette=['#469990','#000075']) sns.pointplot

Customizing titles in Seaborn FacetGrid based on facet

旧巷老猫 提交于 2020-06-01 05:43:05
问题 want to make a facet grid with variable names as the columns, and departments as the rows, and each small chart is a scatter chart of y=value and x=date My data is sort of like this: import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from datetime import datetime import matplotlib.dates as mdates import random datelist = pd.date_range(start="march 1 2020", end="may 20 2020", freq="w").tolist() varlist = ["x", "y", "z", "x", "y", "z", "x", "y", "z", "x

Extra Plot when drawing Catplot

本秂侑毒 提交于 2020-06-01 05:24:27
问题 Using the following code: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline df1 = pd.DataFrame( {'category': {0: 'Cat', 1: 'Cat', 2: 'Cat', 3: 'Cat', 4: 'Dog', 5: 'Dog', 6: 'Dog', 7: 'Dog', 8: 'Dog', 9: 'Dog', 10: 'Dog', 11: 'Dog', 12: 'Dog', 13: 'Dog', 14: 'Dog', 15: 'Dog', 16: 'Dog', 17: 'Dog', 18: 'Dog', 19: 'Dog'}, 'shape': {0: 'Small', 1: 'Small', 2: 'Small', 3: 'Small', 4: 'Small', 5: 'Small', 6: 'Small', 7: 'Medium', 8: 'Medium', 9: 'Large',

Seaborn plot bar time series x-axis : how to display the value of each bar

半世苍凉 提交于 2020-05-31 22:26:58
问题 How to display value of each bar when your figure (bar) has time series as X-axis : I have a dataframe df_final_seaborn : Covid-19 Madagascar Isan'ny olona Daty 2020-05-24 Sitrana isan'andro 4 2020-05-24 Maty 0 2020-05-25 Marary isan'andro 15 2020-05-25 Sitrana isan'andro 5 2020-05-25 Maty 0 and to plot bar with the following code : sns.set(rc={'figure.figsize':(30,15)},palette=['#F70A0A','#2A930C','#930C85'], font_scale=1.7) # pour les axes ax = sns.barplot(x=df_final_seaborn.index,y='Isan\

Seaborn plot bar time series x-axis : how to display the value of each bar

空扰寡人 提交于 2020-05-31 22:25:29
问题 How to display value of each bar when your figure (bar) has time series as X-axis : I have a dataframe df_final_seaborn : Covid-19 Madagascar Isan'ny olona Daty 2020-05-24 Sitrana isan'andro 4 2020-05-24 Maty 0 2020-05-25 Marary isan'andro 15 2020-05-25 Sitrana isan'andro 5 2020-05-25 Maty 0 and to plot bar with the following code : sns.set(rc={'figure.figsize':(30,15)},palette=['#F70A0A','#2A930C','#930C85'], font_scale=1.7) # pour les axes ax = sns.barplot(x=df_final_seaborn.index,y='Isan\

Seaborn FacetGrid plot two different y axis next to eachother

天涯浪子 提交于 2020-05-31 00:00:10
问题 This works, but I'm sure there's got to be a way to do this via FacetGrid. Im imagining some kind of parameter where you can access where the chart is located on the grid. Or maybe this was considered redundant and using plt.subplots is the way to access the axis of the grid. fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2) sns.catplot(x='not.fully.paid', y='int.rate', kind='box', data=loans, ax=ax1) sns.catplot(x='not.fully.paid', y='fico', kind='box', data=loans, ax=ax2) Even when I call

Seaborn Heatmap with single column

痞子三分冷 提交于 2020-05-29 08:24:05
问题 I have a dataframe that has an index (words) and a single column (counts) for some lyrics. I am trying to create a heatmap based on the word counts. Cuenta Que 179 La 145 Y 142 Me 113 No 108 I am trying to produce the heatmap like this: df1 = pd.DataFrame.from_dict([top50]).T df1.columns = ['Cuenta'] df1.sort_values(['Cuenta'], ascending = False, inplace=True) result = df1.pivot(index=df1.index, columns='Cuenta', values=df1.Cuenta.count) sns.heatmap(result, annot=True, fmt="g", cmap='viridis'