doomslyr
doomslyr

Reputation: 11

Not getting the required boxplot output

def univariate_numerical(data,col,title):
    sns.set_style('whitegrid')
    sns.set_context('talk')
    plt.rcParams["axes.labelsize"] = 20
    plt.rcParams['axes.titlesize'] = 22
    plt.rcParams['axes.titlepad'] = 30
    
    plt.title(title)
    plt.yscale('log')
    sns.boxplot(data= data, x=col,orient='v')
    plt.show()

univariate_numerical(data=target0_df,col='Amount_Total',title='Distribution of amount')

Desired plot:

What I Need:

Actual plot:

What I Get

What am I missing?

Upvotes: 1

Views: 56

Answers (1)

Patrick Bormann
Patrick Bormann

Reputation: 749

I believe you still need a y Orientation.

The solution lies in changing the x col to actually y, You can still add a x however: This produces:Box plot

def univariate_numerical(data,col,title):
    sns.set_style('whitegrid')
    sns.set_context('talk')
    plt.rcParams["axes.labelsize"] = 20
    plt.rcParams['axes.titlesize'] = 22
    plt.rcParams['axes.titlepad'] = 30
    
    plt.title(title)
    plt.yscale('log')
    
    sns.boxplot(data= data, y=col, x=data["Amount_Total"].value_counts(), orient='v')
    plt.show()

univariate_numerical(data=df, col='Amount_Total',title='Distribution of amount')

Does this solution meet your requirements?

Upvotes: 1

Related Questions