0% found this document useful (0 votes)
8 views8 pages

Python Matplotlip

The document provides instructions for data visualization using Matplotlib, including creating line plots, bar charts, and scatter diagrams. It outlines specific tasks such as plotting sine curves, visualizing height vs weight from a dataset, and generating sales data visualizations from CSV files. Additionally, it includes requirements for styling plots and displaying multiple datasets in various formats.

Uploaded by

phiqueo11
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)
8 views8 pages

Python Matplotlip

The document provides instructions for data visualization using Matplotlib, including creating line plots, bar charts, and scatter diagrams. It outlines specific tasks such as plotting sine curves, visualizing height vs weight from a dataset, and generating sales data visualizations from CSV files. Additionally, it includes requirements for styling plots and displaying multiple datasets in various formats.

Uploaded by

phiqueo11
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

Data Visualization with Matplotlib

1 Line Plot - Bar Chart - Scatter Diagram - Histogram


1.1 Create the x variable with 200 elements from -10 to 10. Create the y
variable which has the sine ([Link]()) of x.
Requirements:
• Plot the curve

[16]: from matplotlib import pyplot as plt


import numpy as np
x = [Link](-10,10,200)
y = [Link](x)
[Link](x,y)
[Link]()

• plot the elements of x (above exercise):


– with an x
– with a green o

1
[21]: ??

• Plot only the elements:


– from the index 50 to 80
– from the index 51 to 56

[22]: ??

2
1.2 Given the dataset [Link]. Generate plots described as follows:
• use df[].values to get a numpy array out of the data-frame columns
• plot the height vs weight

[23]:

3
• plot the male with blue and female with red in the same plot

[24]: ??

1.3 Given a csv file ‘[Link]’. Generate line plots describe as follows:
• Read the Total profit of all months and show it using a line plot.
• The Total profit data is provided for each month. Generated line plot must include the
following properties:

4
– X label name = Month Number
– Y label name = Total profit

[37]: ??

• Get Total profit of all months and show line plot with the following Style properties:
– Line Style dotted and Line-color should be red
– Show legend at the lower right location.
– X label name = Month Number
– Y label name = Sold units number
– Add a circle marker. • Line marker color as read • Line width should be 3

[29]: ??

5
• Read all product sales data and show it using a multiline plot

[31]: ??

• Read face cream and facewash product sales data and show it using the bar chart

6
[33]: import pandas as pd
import [Link] as plt
df = pd.read_csv("[Link]")
monthList = df ['month_number'].values
faceCremSalesData = df ['facecream'].values
faceWashSalesData = df ['facewash'].values
[Link]([a-0.25 for a in monthList], faceCremSalesData, width= 0.25, label =␣
,→'Face Cream sales data', align='edge')

[Link]([a+0.25 for a in monthList], faceWashSalesData, width= -0.25, label =␣


,→'Face Wash sales data', align='edge')

[Link]('Month Number')
[Link]('Sales units in number')
[Link](loc='upper left')
[Link](' Sales data')
[Link](monthList)
[Link](True, linewidth= 1, linestyle="--")
[Link]('Facewash and facecream sales data')
[Link]()

• Read the total profit of each month and show it using the histogram to see most common
profit ranges

[35]: ??

7
• Read Bathing soap facewash of all months and display it using the Subplot

[36]: ??

You might also like