How many bad habits do people maintain?
Several years ago, FiveThirtyEight conducted a survey among people across the USA about their steak preferences, cigarette smoking, and a few other risk-related questions. The input for this Figure Friday is a small dataset containing yes/no responses from approximately 500 individuals.
Idea & Approach
When working with data, the goal isn’t to start with a specific visualization in mind and then shape the data to fit it. That said, I more or less did exactly that: I had been wanting to create a mirrored horizontal bar chart for a while, and this dataset happened to be perfect for it. It included a column for gender, a few attributes like Household Income, Education, and Age Group, and about seven yes/no columns covering bad habits. The questions addressed topics such as smoking, drinking, gambling, and infidelity.
Incidentally, the dataset also lent itself well to statistical analysis, though that tends to be time-consuming.
Preparing the data for the visual required minimal cleaning or transformation. The actual programming was done in part with the help of the free version of ChatGPT. I built the core structure myself, including filters that adjust the data based on user selections. Some manual work remains essential, to keep your brain from getting rusty. When things took too long, I consulted ChatGPT, for instance when combining mirroring by gender with stacking (e.g., one bar representing women aged 60 and over).
Result
The final visualization shows, for the selected habits and perspective, the breakdown by men and women and within each group, how many people answered “yes, I do this” to anywhere from 0 to a maximum of 7 habits.
The example includes:
- Interaction that allows the same visualization to be viewed from different perspectives: Household Income, Education, and Age Group.
- The option to select one or more habits, showing how many men and women within the chosen perspective responded positively to one or more of the selected habits.
- A Mirrored Horizontal Bar Chart, in other words, a visualization that displays men and women separately.
Figure Friday is een initiatief van de Dash/Plotly community waarbij je elke vrijdag een dataset krijgt en mensen een visual of kleine app maken, waarbij ze inzichten uit de dataset proberen te krijgen. De vrijdag daarop om 18:00, is er een zoomsessie waarbij sommigen uitleggen waarom ze gemaakt hebben wat ze tonen. In de thread op de communitysite wordt ook de code gedeeld, om van elkaar te leren en als het kan een demo.
