Suleka_28
Suleka_28

Reputation: 2919

factorplot main title overlaps sub titles in seaborn

I have produced the below chart. As you can see the main title is overlapping the subtitles of the graphs. I tried different methods but none of them seems to be working. I have also attached my code.

enter image description here

def save_multi_columns_categorical_charts(df, chart, columns, y, hue, title, single_statistic=False,
                                          single_statistic_name=None, kind='point', col='Message Size (Bytes)'):
    filename = chart + ".png"
    print("Creating chart: " + title + ", File name: " + filename)
    fig, ax = plt.subplots()
    all_columns = [col,'Back-end Service Delay (ms)', 'Concurrent Users','Scenario Name']
    all_columns.extend(columns)
    df_results = df[all_columns]

    df_results['new_var'] = df_results[col] + ' - ' + df_results['Scenario Name']


    g = sns.factorplot(x="Concurrent Users", y='Throughput (Requests/sec)',
                       hue='new_var', col='Back-end Service Delay (ms)',
                       data=df_results, kind=kind,
                       size=5, aspect=1, col_wrap=2, legend=False)



    plt.subplots_adjust(top=10, left=0.1)
    g.fig.suptitle(title,y=1.08)  # can also get the figure from plt.gcf()
    plt.legend(loc=2, frameon=True, title="Response Time Summary")

    plt.savefig(filename)
    plt.clf()
    plt.cla()
    plt.close(fig)

Upvotes: 2

Views: 1196

Answers (1)

Pulkit Ratna Ganjeer
Pulkit Ratna Ganjeer

Reputation: 321

Try giving the offset of the title from the top of the axes (in points), in order to add some gap between the main title and the underlying graphs as:

plt.title('Title of the plot', pad=100)

Keep increasing the pad value to adjust the gap as per your need.

Upvotes: 1

Related Questions