Hi @parodiadrian3 , I’ve been through the data analysis course and yes a lot of it is kind of confusing at first and hard to find reliable answers on the internet. Most of the answers I found were way more complex than the actual solutions I ended up with. It’s been a month or so since I did this project but I’ll try and help.
When you use matplotlib by itself, you will make a figure and add axes and plots to it and what not but when you’re using seaborn I don’t think you need to do all that.
In your code example below, I think there is unnecessary lines of code.
fig = plt.figure()
ax1 = fig.add_subplot(111)
g = sns.catplot(x=“variable”, col=“cardio”, data= dfB_long, hue=“value”, kind= ‘count’, orient= “v”, ax=ax1)
#plt.close(1)
Instead of that, try this and see if the cat plot passes or at least displays the same. Let me know the result.
g = sns.catplot(x=“variable”, col=“cardio”, data= dfB_long, hue=“value”, kind= ‘count’, orient= “v”, ax=ax1).figure
fig = g
It’s late so I didn’t actually run through your code yet but if what you’re saying is true and your graph is identical to the test then this should work. All I did delete all the other lines of code from your previous code block since seaborn doesn’t need those and I added .figure
at the end of it to make it a figure and then in replit I made the value of fig
equal g
. In Replit, fig
was given to us to define. This is how the figure is saved and then returned to us in an image, in Replit. It may not work and you may need to change some of the keyword arguments within the catplot function (for ex: changing kind=
to bar
instead of count
), but for now lets see how this line of code works out.
EDIT:
I went into your code and saw that the first graphs code was this:
# Draw the catplot with 'sns.catplot()'
g = sns.catplot(x="variable",
col="cardio",
data=df_cat,
hue="value",
kind='count',
orient="v")
g.set_axis_labels("variable", "total")
# Get the figure for the output
fig = g
The ONLY issue is that fig = g
needs to be in figure format. So literally just change that to fig = g.figure
, and everything but the final test passes. You cleaned your data and created the graph a bit different than I did so my first suggestion didn’t work because you can’t set axis labels after you use .figure
.
FINAL EDIT:
As for the heatmap, you’re having the same issue I had, I got your final test to pass by changing one part of the dataframe cleaning process. Your final values are slightly off because when removed the blood pressure, weight and height values, you first removed the blood pressure, and THEN removed height and weight. When the blood pressure values were removed, some of the height and weights were also removed. Readdress that section and let me know the results. 
P.S. The colors don’t have to be exact to pass the test but if you want them to be then try adding this to your keyword arguments in the heatmap function:
vmin=-0.16,
vmax=0.32,
center=0.0,
cbar_kws={'shrink': 0.5, 'ticks': [0.24, 0.16, 0.08, 0.00, -0.08]}
# vmin sets the bottom range of the colorbar (not the tick, the range)
# vmax sets the top range of the colorbar (not the tick, the range)
# center sets 0.0 as the center color of the colorbar (making 0.0 values black)
# cbar_kws first shrinks the colorbar a bit and then sets the ticks to match the example