factorplot主标题与seaborn中的副标题重叠

时间:2019-03-08 06:23:00

标签: python-3.x matplotlib plot formatting seaborn

我制作了下图。如您所见,主标题与图形的字幕重叠。我尝试了不同的方法,但似乎都没有用。我还附上了我的代码。

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)

0 个答案:

没有答案