4

I have a data frame which is described as below:

     dataset   method     score      input_shape
0  A dataset   method1    0.9        K=64
0  A dataset   method2    0.9        K=64
0  A dataset   method1    0.9        K=32
0  A dataset   method2    0.9        K=32
0  A dataset   method3    0.9        L=1000
0  A dataset   method3    0.9        L=2000
0  B dataset   method1    0.9        K=64
0  B dataset   method2    0.9        K=64
0  B dataset   method1    0.9        K=32
0  B dataset   method2    0.9        K=32
0  B dataset   method3    0.9        L=1000
0  B dataset   method3    0.9        L=2000

I am trying to use seaborn.catplot() to plot this datagram, to compare with performances under different dataset, and method, and input shape. Below is my code and the result I got:

sns.catplot(x='method', y='score', col="dataset", \
            data=df, kind="bar",hue='input_shape', \
            palette='Set2', height=5, aspect=1)

catplot result

I observed that these bars are not centering with x-label due to some of my hue class is empty, but this result is not what I want. Is there any way to remove these empty class on the plot, making these bars can center with x-label (even without using catplot())?

Any suggestion is welcomed.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
John
  • 41
  • 3

0 Answers0