0% found this document useful (0 votes)
2 views7 pages

Matplotlib Pyplot Aritra Gupta

The document is an assignment by Aritra Gupta for an ESS245 course, focusing on using Matplotlib's pyplot for data visualization. It includes code snippets for generating sine and cosine plots, adding legends, creating separate plots, and modifying plot aesthetics. The assignment demonstrates various plotting techniques and customization options in Matplotlib.

Uploaded by

Simba Gupta
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)
2 views7 pages

Matplotlib Pyplot Aritra Gupta

The document is an assignment by Aritra Gupta for an ESS245 course, focusing on using Matplotlib's pyplot for data visualization. It includes code snippets for generating sine and cosine plots, adding legends, creating separate plots, and modifying plot aesthetics. The assignment demonstrates various plotting techniques and customization options in Matplotlib.

Uploaded by

Simba Gupta
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

Matplotlib-pyplot-Aritra-Gupta

November 29, 2021

1 ESS245 Matplotlib pyplot Assignment


Date: Nov 25rd, 2021
First Name: Aritra
Last Name: Gupta
Student ID: 1004835770
[ ]: import numpy as np
import math

# generate a numpy array filled with values from


# zero to 2*pi with a step size of 0.1
x_1: [Link] = [Link](0, [Link] * 2, 0.1)
y_1: [Link] = [Link](x_1) # calculate the sin(x)
y_2: [Link] = [Link](x_1) # calculate the cos(x)
y_3: [Link] = [Link](x_1)** 2 + 2 # calculate the cos(x*2)+2
y_4: [Link] = y_3 + +y_2 + y_1 # calcualte the sum y1 to y3

[2]: #Question 1, create plot with x_1 and y_1 with matplotlib and have X and Y be␣
,→the axes titles

import [Link] as plt

fig: [Link]
ax: [Link]

fig,ax1 = [Link]()
[Link](x_1,y_1)
[Link](f"X")
[Link](f"Y")
[Link]()

1
[3]: #Question 2, add legend to previous
import [Link] as plt

fig: [Link]
ax: [Link]

fig,ax1 = [Link]()
[Link](x_1,y_1)
[Link](f"X")
[Link](f"Y")
[Link](["$y=sin(x)$ for $x=0$ to $x=2*\pi$"]) #legend
[Link]()

2
[4]: #Question 3, add legend and line for y_4 using the correct equation.

import [Link] as plt

fig: [Link]
ax1: [Link]
ax2: [Link]
fig,ax1 = [Link]()
[Link](x_1,y_1, color="C1")
ax2=[Link]()
[Link](y_4)
[Link](f"X")
[Link](f"Y")
[Link](["$y=sin(x)$ for $x=0$ to $x=2*\pi$"], loc=(0.02,0.9), frameon=False)
[Link](["y_4=y_3+y_2+y_1"])
[Link]()

3
[10]: #Question 4, make the plots separate and add title
import [Link] as plt

fig: [Link]
ax1: [Link]
ax2: [Link]

fig,[ax1,ax2] = [Link](nrows=2, ncols=1)


fig.set_size_inches(8, 5)
[Link](x_1,y_1, color="C2")
[Link](y_4)
ax1.set_title(f"$y=sin(x)$ for $x=0$ to $x=2*\pi$")
ax2.set_title("y_4=y_3+y_2+y_1")
ax1.set_xlabel("X")
ax1.set_ylabel("Y")
ax2.set_xlabel("X")
ax2.set_ylabel("Y")
[Link](f"Y")
[Link](f"HEYO")
[Link]()

4
[21]: #Question 5, add a scatter plot on top of y_1
import [Link] as plt

fig: [Link]
ax1: [Link]

fig,ax1 = [Link]()

[Link](x_1,y_1, color="C9")
[Link](x_1,y_1, color="C6")
ax1.set_xlabel(f"X")
ax1.set_ylabel(f"Y")
[Link](["$Lines$", "$Dots$"]) #legend
[Link]()

5
[20]: #Question 6, change colour and width of line to 4
import [Link] as plt

fig: [Link]
ax1: [Link]

fig,ax1 = [Link]()

[Link](x_1,y_1, color="C9")
[Link](x_1,y_1, color="C6", linewidth=4)
ax1.set_xlabel(f"X")
ax1.set_ylabel(f"Y")
[Link](["$Lines$", "$Dots$"]) #legend
[Link]()

6
[ ]:

You might also like