0% found this document useful (0 votes)
3 views6 pages

PyPlot Data Visualization Techniques

The document outlines an assignment involving various plotting tasks using PyPlot in Python. It includes instructions for creating line charts, bar charts, histograms, and visualizing stock prices and sales data. Sample code snippets are provided for each task to illustrate how to implement the plots.

Uploaded by

debojitghosh4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

PyPlot Data Visualization Techniques

The document outlines an assignment involving various plotting tasks using PyPlot in Python. It includes instructions for creating line charts, bar charts, histograms, and visualizing stock prices and sales data. Sample code snippets are provided for each task to illustrate how to implement the plots.

Uploaded by

debojitghosh4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment 4- Plotting with PyPlot

1. Plotting a line chart of “Month Name” versus “Monthly


Saving” given below.
2. The prices of a stock for 3 months are given. Write a program to
show the variations in prices for each month by 3 lines on same
line chart. Make sure to add legends and labels. Show grid also.

Answer
import [Link] as plt
months = ['January', 'February', 'March']
prices_stock_A = [100, 120, 110]
prices_stock_B = [90, 110, 100]
prices_stock_C = [95, 115, 105]
[Link](months, prices_stock_A, label='Stock A', marker='o')
[Link](months, prices_stock_B, label='Stock B', marker='s')
[Link](months, prices_stock_C, label='Stock C', marker='^')
[Link]('Months')
[Link]('Prices')
[Link]('Stock Prices Variation')
[Link]()
[Link](True)
[Link]()
3. The file “[Link]” have stored the sales(in Rs)
made in first six months for four years. Year – wise sales
of first six months. Plot bar chart for following data.
4.
Day-wise sales data along with Day’s names
Week Week Week
Day
1 2 3
5000 4000 4000 Monday
5900 3000 5800 Tuesday
6500 5000 3500 Wednesday
3500 5500 2500 Thursday
4000 3000 3000 Friday
5300 4300 5300 Saturday
7900 5900 6000 Sunday
Answer:
import pandas as pd

import [Link] as plt

df= pd.read_csv(r"D:\\ [Link]")

# plots a bar chart with the column “Days” as x axis

[Link](kind='bar',x='Day',title='Sales Report')

#set title and set ylabel

[Link]('Sales in Rs')

[Link]()
5.
Displays the histogram corresponding to all attributes having numeric values, i.e.,
‘Height’ and ‘Weight’ attributes as shown in Figure below. On the basis of the height and
weight values provided in the DataFrame, the plot() calculated the bin values.

Name Height Weight


0 Arnav 60 47
1 Sheela 61 89
2 Azhar 63 52
3 Bincy 65 58
4 Yash 61 50
5 Nazar 60 47

Answer:
import pandas as pd
import [Link] as plt
data = {"Name":["Arnav", "Sheela", "Azhar", "Bincy",
"Yash",
"Nazar"],
"Height" : [60,61,63,65,61,60],
"Weight" : [47,89,52,58,50,47]}
df=[Link](data)
print(df)
[Link](kind="hist")
[Link]()
6.
Collect the minimum and maximum temperature of your city for a week and
present it using a histogram plot.

Answer:
import pandas as pd
import [Link] as plt
min_temp=[6,6,9,11,12,13,11]
max_temp=[16,15,15,16,18,19,15]
[Link]([min_temp,max_temp],bins=5,color=["yellow","r
ed"],edgecolor="black")
[Link]("Minimum and Maximum Temperatures in city
During Fenruary 2021")
[Link]("Frequency")
[Link]("Temperature")
[Link]()

You might also like