Matplotlib
(Plotting data)
Matplotlib
Plotting Temperature against Height
INPUTS
import [Link] as plt
# list storing date in string format
date = ["25/12", "26/12", "27/12"]
# list storing temperature values
temp = [8.5, 10.5, 6.8]
# create a figure plotting temp versus date
[Link](date, temp, marker='o')
# add labels and title
[Link]("Date")
[Link]("Temperature (°C)")
[Link]("Temperature Variation")
# show the figure
[Link]()
LINE GRAPH
Plotting Avg. Weight with respect to avg. Height
INPUTS
import [Link] as plt
import pandas as pd
# data
height = [119.9, 124.5, 129.5, 134.6, 130.7, 147.3, 152.4, 157.0, 162.0]
weight = [19.7, 21.3, 23.5, 25.9, 28.5, 32.1, 35.7, 39.6, 43.2]
# create dataframe
df = [Link]({"height": height, "weight": weight})
# set labels
[Link]("Weight in kg")
[Link]("Height in cm")
[Link]("Average weight with respect to average height")
# plot with marker and green dash-dot line
[Link](df["weight"], df["height"],
marker='*', markersize=10,
color='green', linewidth=2, linestyle='dashdot')
[Link]()
Plotting Carnival Sales Report
INPUTS
# Create a DataFrame
df = [Link](data)
# Save the DataFrame to a CSV file
df.to_csv("Daywise_Sales.csv", index=False)
# Read CSV file (use your actual file '[Link]' if provided)
df = pd.read_csv("Daywise_Sales.csv")
# Plot a bar chart
[Link](kind="bar",
x="Day",
y="Sales",
title="Carnival Sales Report",
color=["red", "yellow", "purple", "orange", "blue", "green", "pink"],
edgecolor="green",
linewidth=2)
# Set Y-axis label
[Link]("Sales in Rs")
[Link]()
Tickets Sold Throughout the Week
INPUTS
import [Link] as plt
# Data
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
tickets_sold = [2000, 2800, 3000, 2500, 2300, 2500, 1000]
# Plotting the line plot with magenta color
[Link](days, tickets_sold, color='magenta', marker='o', linestyle='*', linewidth=2)
# Title and labels
[Link]("Tickets Sold Throughout the Week")
[Link]("Day")
[Link]("Tickets Sold")
[Link]()