Graph Plotting
Graph Plotting
Scatter plot
Scatter plot of exponential function : 𝐞𝐱𝐩(𝐱)
Contour plot
Contour plot : 𝒁 = 𝑿𝟐 + 𝒚𝟐
Bar plot
Bar plot of a data set by defining a dictionary
np.arange(a, b, stepsize)
np.linspace(a, b, number of stepes)
Plotting: 𝒙, 𝒙𝟐 , 𝒙𝟑
# Simple plotting with modification
import numpy as np
import matplotlib.pyplot as plt
...
plt.figure(figsize=(10, 6), dpi=80)
plt.plot(X, C, color="blue", linewidth=2.5, linestyle="-")
plt.plot(X, S, color="red", linewidth=2.5, linestyle="-")
...
Z = np.sqrt(X**2 + Y**2)
plt.title('Contour Plot')
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# creating the dataset
data = {'C':20, 'C++':15, 'Java':30, 'Python':35}
courses = list(data.keys())
values = list(data.values())
# creating the dataset
plt.figure(figsize = (5, 5))
# creating the bar plot
plt.bar(courses, values, color =‘blue', width = 0.4)
# Labeling the X and Y axis
plt.xlabel("Courses offered")
plt.ylabel("No. of students enrolled")
plt.title("Students enrolled in different courses")
plt.show()
Question 3: Write a python script for subplot of function 𝒔𝒆𝒄𝒙 and 𝟏/𝒙