plot with two categories

# Step 1: Create a dataset with two categories
set.seed(123)
category <- rep(c("Category A", "Category B"), each = 50)
value <- c(rnorm(50, mean = 0, sd = 1), rnorm(50, mean = 2, sd = 1))
data <- data.frame(Category = category, Value = value)

# Step 2: Create a boxplot to visualize the distribution of each category
boxplot(Value ~ Category, data = data, col = c("skyblue", "lightgreen"),
        main = "Boxplot of Categories A and B",
        xlab = "Category",
        ylab = "Value")

# Step 3: Add points to the boxplot to show individual data points
stripchart(Value ~ Category, data = data, method = "jitter",
           add = TRUE, col = "red", pch = 16)

# Step 4: Add legend to the plot
legend("topright", legend = levels(data$Category), fill = c("skyblue", "lightgreen"), title = "Category")

# Step 5: Add gridlines to the plot
grid()

# Step 6: Customize the axis labels
axis(1, at = c(1, 2), labels = c("Category A", "Category B"))

# Step 7: Customize the plot margins
par(mar = c(5, 4, 4, 2) + 0.1)

# Step 8: Display the plot