seaborn

imshow and plot side by side

有些话、适合烂在心里 提交于 2019-12-24 07:14:43
问题 I'm trying to put side-by-side numpy array displayed as image and seaborn distplot of the same array. I've came up with the following function: def visualize(arr): f, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw = {'width_ratios': [1, 3]}) ax1.imshow(arr) flat = arr.flatten() x = flat[~np.isnan(flat)] sns.distplot(x, ax=ax2) plt.show() which produces: As you can see, the image has smaller height than the plot. How can I modify my function in order to have the same height for the plot and the

imshow and plot side by side

旧巷老猫 提交于 2019-12-24 07:14:04
问题 I'm trying to put side-by-side numpy array displayed as image and seaborn distplot of the same array. I've came up with the following function: def visualize(arr): f, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw = {'width_ratios': [1, 3]}) ax1.imshow(arr) flat = arr.flatten() x = flat[~np.isnan(flat)] sns.distplot(x, ax=ax2) plt.show() which produces: As you can see, the image has smaller height than the plot. How can I modify my function in order to have the same height for the plot and the

plotting & formatting seaborn chart from pandas dataframe

老子叫甜甜 提交于 2019-12-24 05:46:13
问题 I have a pandas dataframe al_df that contains the population of Alabama from a recent US census. I created a cumulative function that I plot using seaborn , resulting in this chart: The code that relates to the plotting is this: figure(num=None, figsize=(20, 10)) plt.title('Cumulative Distribution Function for ALABAMA population') plt.xlabel('City') plt.ylabel('Percentage') #sns.set_style("whitegrid", {"ytick.major.size": "0.1",}) plt.plot(al_df.pop_cum_perc) My questions are: 1) How can I

Seaborn boxplot box assign custom edge colors from Python list

隐身守侯 提交于 2019-12-24 05:29:22
问题 I am trying to change the appearance of boxes in Seaborn's boxplot. I would like all boxes to be transparent and for the box borders to be specified from a list. Here is the code I am working with: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt fig, ax = plt.subplots() df = pd.DataFrame(np.random.rand(10,4),columns=list('ABCD')) df['E'] = [1,2,3,1,1,4,3,2,3,1] sns.boxplot(x=df['E'],y=df['C']) # Plotting the legend outside the plot (above) box = ax

Seaborn boxplot box assign custom edge colors from Python list

半腔热情 提交于 2019-12-24 05:29:10
问题 I am trying to change the appearance of boxes in Seaborn's boxplot. I would like all boxes to be transparent and for the box borders to be specified from a list. Here is the code I am working with: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt fig, ax = plt.subplots() df = pd.DataFrame(np.random.rand(10,4),columns=list('ABCD')) df['E'] = [1,2,3,1,1,4,3,2,3,1] sns.boxplot(x=df['E'],y=df['C']) # Plotting the legend outside the plot (above) box = ax

seaborn heatmap pandas calculation on isnull

北城余情 提交于 2019-12-24 05:12:10
问题 producing a series calculation of a dataframe to provide a percentage of NaN's to the total amount of rows as shown: data = df.isnull().sum()/len(df)*100 RecordID 0.000000 ContactID 0.000000 EmailAddress 0.000000 ExternalID 100.000000 Date 0.000000 Name 0.000000 Owner 67.471362 Priority 0.000000 Status 0.000000 Subject 0.000000 Description 0.000000 Type 0.000000 dtype: float64 What I'm keen to do is represent this as a heatmap in seaborn sns.heatmap(data) , drawing the readers attention those

seaborn heatmap pandas calculation on isnull

家住魔仙堡 提交于 2019-12-24 05:12:05
问题 producing a series calculation of a dataframe to provide a percentage of NaN's to the total amount of rows as shown: data = df.isnull().sum()/len(df)*100 RecordID 0.000000 ContactID 0.000000 EmailAddress 0.000000 ExternalID 100.000000 Date 0.000000 Name 0.000000 Owner 67.471362 Priority 0.000000 Status 0.000000 Subject 0.000000 Description 0.000000 Type 0.000000 dtype: float64 What I'm keen to do is represent this as a heatmap in seaborn sns.heatmap(data) , drawing the readers attention those

How to use multiple colormaps in seaborn on same plot

℡╲_俬逩灬. 提交于 2019-12-24 03:12:07
问题 I have some test data: import numpy as np x_data = np.arange(10) y = np.random.rand(len(x_data)) With different properties ix1 = x_data < 5 ix2 = x_data >= 5 I want to investigate the differences visually, but am messing the plot up: import matplotlib.pyplot as plt import seaborn as sns sns.set_context('poster') fig, ax = plt.subplots(figsize=(4, 4)) for i, x in enumerate(x_data): if ix1[i]: sns.set_palette('rainbow', sum(ix1)) if ix2[i]: sns.set_palette('coolwarm', sum(ix2)) plt.plot(x, y[i]

How to use multiple colormaps in seaborn on same plot

家住魔仙堡 提交于 2019-12-24 03:12:02
问题 I have some test data: import numpy as np x_data = np.arange(10) y = np.random.rand(len(x_data)) With different properties ix1 = x_data < 5 ix2 = x_data >= 5 I want to investigate the differences visually, but am messing the plot up: import matplotlib.pyplot as plt import seaborn as sns sns.set_context('poster') fig, ax = plt.subplots(figsize=(4, 4)) for i, x in enumerate(x_data): if ix1[i]: sns.set_palette('rainbow', sum(ix1)) if ix2[i]: sns.set_palette('coolwarm', sum(ix2)) plt.plot(x, y[i]

Python: Plotting percentage in seaborn bar plot

£可爱£侵袭症+ 提交于 2019-12-24 00:52:50
问题 For a dataframe import pandas as pd df=pd.DataFrame({'group':list("AADABCBCCCD"),'Values':[1,0,1,0,1,0,0,1,0,1,0]}) I am trying to plot a barplot showing percentage of times A, B, C, D takes zero (or one). I have a round about way which works but I am thinking there has to be more straight forward way tempdf=df.groupby(['group','Values']).Values.count().unstack().fillna(0) tempdf['total']=df['group'].value_counts() tempdf['percent']=tempdf[0]/tempdf['total']*100 tempdf.reset_index(inplace