From 4169bb46c6a25c858a96fdad0ec36dc379126686 Mon Sep 17 00:00:00 2001 From: Divya-15-09 Date: Mon, 19 May 2025 23:58:31 +0530 Subject: [PATCH] Update 2-bar-plot.ipynb --- src/2-bar-plot.ipynb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/2-bar-plot.ipynb b/src/2-bar-plot.ipynb index 9d3fb712..fc399fe8 100644 --- a/src/2-bar-plot.ipynb +++ b/src/2-bar-plot.ipynb @@ -15,6 +15,20 @@ "source": [ "# TASK: Create a bar plot with the following data: categories = ['A', 'B', 'C', 'D'] and values = [5, 7, 3, 9].\n", "# Use different colors for each bar and add a title to the plot." +import matplotlib.pyplot as plt + +# Data +categories = ['A', 'B', 'C', 'D'] +values = [5, 7, 3, 9] +colors = ['red', 'blue', 'green', 'orange'] # Different colors for each bar + +# Plotting +plt.bar(categories, values, color=colors) +plt.title("Bar Plot of Categories") +plt.xlabel("Categories") +plt.ylabel("Values") +plt.show() + ] } ],