Wednesday, August 9, 2023

Q5) Plot the following data on a line chart and customize the chart according to the below-given instructions:

import matplotlib.pyplot as plt

 

# Data

months = ["January", "February", "March", "April", "May"]

sales = [510, 350, 475, 580, 600]

 

# Create a line chart

plt.figure(figsize=(10, 6))  # Set the figure size

plt.plot(months, sales, color='blue', linestyle='--', marker='D', label='Sales')  # Line style, marker, and label

 

# Title and labels

plt.title("The Monthly Sales Report")

plt.xlabel("Month")

plt.ylabel("Sales")

 

# Legends

plt.legend()

 

# Show the plot

plt.show()

 

No comments:

Post a Comment