Category : seaborn

The objective is to create subplot for the jointplot annotate with correlation. However, when plt.show(), the figure were displayed separately. May I know how to solve this issue? import numpy as np import pandas as pd import scipy.stats as stats import seaborn as sns import matplotlib.pyplot as plt ncols=[‘ra’,’rb’,’a’,’b’,’c’,’d’] df=pd.DataFrame(np.random.rand(100,len(ncols)),columns=ncols) nvars=[‘a’,’b’,’c’,’d’] rt=[‘a’,’b’] fig, axs = ..

Read more

I am using following code to plot returned/non returned products percentage (y-axis) with respect to percentage of discount given on these products (x-axis). If you see, all bars will add to 100 percent. sns.histplot(data=df_c, x=’percent_discount_100′, hue=’returned’,binwidth=10, stat=’percent’, ax=ax) #ax.set_xlim(1,31) #ax.set_xticks(range(0,100,10)) plt.show() What I want is to change percentage information on each bar, what I mean ..

Read more

I have a sample dataframe as given below. import pandas as pd data = {‘ID’:[‘001’, ‘002’, ‘003’, ‘004’, ‘005’], ‘Aim2 Date’:[‘9/3/19’, ‘9/3/19’, ‘9/13/19’, ‘9/20/19’, ‘9/23/19’], ‘Aim2 C/I’ :[‘Intervention’, ‘Intervention’, ‘Intervention’, ‘Control’, ‘Intervention’], ‘Aim3 Date’:[‘9/17/19′,’9/19/19′,’9/27/19′,’9/30/19′,’10/8/19’], ‘Aim3 C/I’ :[‘Control’, ‘Intervention’, ‘Control’, ‘Withdraw’, ‘Withdraw’]} df = pd.DataFrame(data) The goal is to create a heatmap where the 2 columns ..

Read more

Please i cant understand the reason for this error message. My code is below: After running the code it outputs the following error messages: ERROR: test_data_cleaning (test_module.DataCleaningTestCase) TypeError: ‘AxesSubplot’ object is not subscriptable import matplotlib.pyplot as plt import pandas as pd import seaborn as sns from pandas.plotting import register_matplotlib_converters register_matplotlib_converters() # Import data (Make sure ..

Read more

I’m trying to create a heatmap from an excel sheet for my friends. However, I got the error I mentioned when I use heatmap function from seaborn. How do I fix this? Code: import pandas as pd import seaborn as sns import matplotlib.pylab as plt df=pd.read_excel("attrition.xlsx",usecols="B,F,G,I:K,M:O,Q,S,T,W:AH") sns.heatmap(df) plt.show() I only use specific columns because those ..

Read more

Am trying to use seaborn to do a subplot, and i goy the message AttributeError: ‘Figure’ object has no attribute ‘boxplot’ df_box = df.copy() df_box.reset_index(inplace=True) df_box[‘year’] = [d.year for d in df_box.date] df_box[‘month’] = [d.strftime(‘%b’) for d in df_box.date] axes = plt.subplots(nrows =1, ncols =2, figsize=(12,5)) #= plt.figure(figsize=(12,5)) #fig1 = plt.subplot(1,2,1) axes[0] = sns.boxplot(ax = ..

Read more