Answer to Question #294726 in Python for saanvi

Question #294726

Write a code to plot sine and cosine functions graph using subplot.


1
Expert's answer
2022-02-07T05:10:39-0500
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,4*np.pi-1,0.1)   # start,stop,step
y = np.sin(x)
z = np.cos(x)

fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.plot(x, y)
ax1.set_title('Plot of sin from 0 to 4pi')
ax1.set(xlabel='x values from 0 to 4pi')
ax2.plot(x, z)
ax2.set_title('Plot of cos from 0 to 4pi')
ax2.set(xlabel='x values from 0 to 4pi')

plt.show()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS