import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
"""
Create matrix of ones
"""
a = np.ones((5,10))
# end
"""
First plot y = x
Now plot y = sin(x) on a second y axis
Make the x range 0 to 4 pi
Save to dual.png
"""
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
"""
Create matrix of ones
"""
a = np.ones((5,10))
# end
"""
First plot y = x
Now plot y = sin(x) on a second y axis
Make the x range 0 to 4 pi
Save to dual.png
"""
x = np.arange(0, 4*np.pi, 0.1)
y = np.sin(x)
fig, ax1 = plt.subplots()
ax1.plot(x, y)
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax2 = ax1.twinx()
ax2.plot(x, y, 'r-')
ax2.set_ylabel('y', color='r')
fig.savefig('dual.png')
Go to Google Form