arash tarakmeh
arash tarakmeh

Reputation: 21

plots in matploblib become noisy

so my code are :

import numpy as np
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
x1 = [1, 2, 3, 4, 5]
y1 = [1, 4, 9, 14, 25]
t = np.arange(0.0, 2.0, 0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.sin(4*np.pi*t)

plt.figure(1)
plt.subplots(211)
plt.plot(x, y)
plt.subplots(212)
plt.plot(x1, y1)

plt.figure(2)
plt.subplot(211)
plt.plot(t, s1)
plt.subplot(212)
plt.plot(t, 2*s1)

plt.show()

when I just run fig 2 it's all okay but when I run all the code, plots become noisy also instead of 2 fig it will run an empty fig as fig num1 as u can see the result in pic1 pic

Upvotes: 1

Views: 76

Answers (1)

Phil Leh
Phil Leh

Reputation: 758

You have a small typo inside your code. In the plots belonging to figure(1) change your subplots() to subplot() (remove the trailing s)

Upvotes: 2

Related Questions