Reputation: 346
I am trying to demonstrate the aliasing effect on a sine wave. I have a signal y(x) to be plotted against x with len(x)=180 and another signal y1(x1) to be plotted against x1 with len(x1)= 300.
I have them plotted in different subplots. However, they are the same signal represented by different numbers of points. And wish to overlay those signals in the same subplot. Is that possible?
(i am using python 2.7 with matplotlib)
couldn't find this anywhere.
Upvotes: 2
Views: 4149
Reputation: 284860
Just call plot
twice. Alternately, you can can combine the plot
calls as @tcaswell pointed out.
As an example:
import numpy as np
import matplotlib.pyplot as plt
x1, x2 = [np.linspace(0, 10, num) for num in [10, 100]]
y1 = np.cos(x1)
y2 = np.sin(x2)
plt.plot(x1, y1)
plt.plot(x2, y2)
plt.show()
Upvotes: 7