Visualize a continuous variable against a binary variable I want to visualize a continuous variable, BMI index, against a binary variable, heart disease.
I want to check by visualization in my data, if heart disease is more common among higher BMI index cases than lower BMI. I used catplot boxplot:
Plot = sns.catplot(x="heart_disease", y="bmi", kind="box", 
                   data=data);
Plot.fig.suptitle('Correlation between Heart Disease and 
                   BMI index', size=15, y=1.12);

From the result plot, the question to the answer is no. Do you think using boxplot is a good idea? is there another plot type that could do a better job for the question at hand ?


Boxplots lose an enormous amount of information, since they condense all data into just five summary statistics (the median, the box and the whiskers) plus what is unhappily called "outliers".
I would always go with beanplots, also known as violin plots. If you want, you can always overlay boxplots, or the original data. If you do add the original data, jitter them horizontally to avoid overplotting. (And if you plot both boxplots and the original data, suppress the "outliers" plotted by the boxplots, because then you would have the same data plotted twice.) This answer of mine gives an example (the second plot) and R code to create it. In Python, it seems like you could use statsmodels.graphics.boxplots.beanplot or seaborn.violinplot.
Visually checking relationships is a very good idea. However, it is of course subjective. If you want an objective result, consider running a logistic regression of heart_disease on BMI. Consider using splines to capture any nonlinearities.
