# 06. Stacked barplot

# Introduction

A stacked barplot is a type of bar chart that displays multiple variables stacked on top of each other. Each bar represents a total, and segments within the bar represent the different categories that contribute to that total. This type of visualization is useful for comparing the composition of different groups and understanding the distribution of categories within each group.

In a stacked barplot, the length of each segment is proportional to its value, making it easy to see the relative sizes of the categories. This chart is particularly effective when you want to show the cumulative effect of several variables and compare their contributions across different groups.

# Example

# Message

Create a stacked bar plot showing the number of patients by gender, grouped by stage. Each bar should represent a stage, with sections within the bar indicating gender.

# Results