program -12

Author

K Atharsh

# Load the ggplot2 package
library(ggplot2)

# Sample data
set.seed(123)
data <- data.frame(
  group = rep(c('A', 'B', 'C'), each = 50),
  value = c(rnorm(50, mean = 5), rnorm(50, mean = 7), rnorm(50, mean = 6))
)

# Create the violin plot
ggplot(data, aes(x = group, y = value, fill = group)) +
  geom_violin(trim = FALSE) +        # Violin plot without trimming the tails
  geom_boxplot(width = 0.1, fill = "white") +  # Optional: add a boxplot inside the violins
  labs(title = "Violin Plot of Value by Group", x = "Group", y = "Value") +
  theme_minimal()