How to allow more space for the variable name


#1


The names of many variables are too long. I want to have more space for the names. Thank you!

Here is the code:
`
nullIndex = df_loan_2018q1.isnull().any().index[df_loan_2018q1.isnull().any()]
nullTrain = df_loan_2018q1.loc[:, nullIndex].copy()

for col in nullTrain.columns:
nullPos = nullTrain[col].isnull()
nullTrain.loc[~nullPos, col] = ‘Exist’
nullTrain.loc[nullPos, col] = ‘Null’

nullTrain = nullTrain.apply(lambda x: pd.Series.value_counts(x)).T
nullTrain = nullTrain.sort_values(‘Exist’)

trace1 = go.Bar(
x = nullTrain[‘Exist’],
y = nullTrain.index,
name = ‘Exist’,
orientation = ‘h’,
marker = dict(
color = ‘rgba(246, 78, 139, 0.6)’,
line = dict(
color = ‘rgba(246, 78, 139, 1.0)’,
width = 3)
)
) # the pink one

trace2 = go.Bar(
x = nullTrain[‘Null’],
y = nullTrain.index,
name = ‘Null’,
orientation = ‘h’,
marker = dict(
color = ‘rgba(58, 71, 80, 0.6)’,
line = dict(
color = ‘rgba(58, 71, 80, 1.0)’,
width = 3)
)
) # represent the null values: gray

Picture of Null

data = [trace1, trace2]
layout1 = go.Layout(
width=800, height=1600, barmode=‘stack’, title=‘Null Value BarPlot’)
fig = go.Figure(data=data, layout=layout1)

#print((df_train.isnull().sum()[df_train.isnull().sum() != 0]) / df_train.shape[0])
#print(’’)
py.iplot(fig)`


#2

You can increase the size of the margins in the layout object if you add something like margin=dict(l=160) as I did above.

For more info you can look at the layout references or, more specifically, the layout-margin reference page


#3

Thank you!
I also figured a way to do that:

margin=go.Margin( l=240, # adding the margin on the left r=50, b=100, t=100, pad=4 )