如何用seaborn factorplot绘制多个图?

时间:2019-03-07 21:16:35

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

我的数据框为:

enter image description here

我想使用seaborn创建一个因子图,如下所示: enter image description here

数据为here

注意:播种图中的睡眠时间=后端服务延迟(ms)

我现有的代码如下所示,我不知道如何进行。非常感谢您的帮助。

def save_multi_columns_categorical_charts(df):
   )
    # add_chart_details(title, filename)
    fig, ax = plt.subplots()
    all_columns = df['Throughput (Requests/sec'),'Back-end Service Delay (ms)', 'Concurrent Users','Scenario Name','Message Size (Bytes)']

1 个答案:

答案 0 :(得分:1)

基本上,我需要做的是使用melt:

df_results = df_results.melt(id_vars=['Concurrent Users', col,'Scenario Name','Back-end Service Delay (ms)'],
                        value_vars=['Throughput (Requests/sec)'])

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

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