Medical Data Visualizer Confusion

It wasn’t working for me either…I was plotting the catplot just like others taught before but, although I was getting the graphs right, it was failing the tests:
fig = sns.catplot(x = "variable", hue = "value", col = "cardio", data = df_cat, kind = "count")
The point that others explained was:

  1. The catplot as it is returns a FacetGrid object, thus, you need to get the figure attribute to pass as the return of the “draw_cat_plot” function. Kind of like this:
    g = sns.catplot(x = "variable", hue = "value", col = "cardio", data = df_cat, kind = "count")
    fig = g.fig
    return fig

  2. Finally, you need to set the y-label to ‘total’ instead of ‘count’ to match the testing code. And for that, you can simply say :
    img.set_axis_labels(“variable”, “total”)

And that is it. My catplot results worked fine after this.

4 Likes