Reputation: 539
So I have data, in the form of 2 numpy arrays, that look like the above when plotted. For some reason, when I add the 2 numpy arrays together, element-wise as such:
c = a + b
and then plot c, I get this:
All I'm doing is plot.plot(c)
But that doesn't make sense right? I shouldn't get the same exact plot as plot b (except shifted up) when adding those 2 together right? I'm really confused about this.
Upvotes: 0
Views: 39
Reputation: 11330
I agree with all the other answers above. I think it will be much clearer to the original poster if they try drawing all three plots on the same graph, rather than showing each of them on a separate graph.
plt.plot(a)
plt.plot(b)
plt.plot(a + b)
plt.show()
Upvotes: 0
Reputation: 2414
a
is practically a constant, the variations in a
are much smaller than the variations in b
so when you sum them together you only wind up seeing the variations in b
on a plot. This will be more apparent if you plot c = 1000*a + b
Upvotes: 0
Reputation: 150825
You shouldn't. However, plot can be deceiving. a
is almost constant: max changes is about 2e-3
compare to 0.7
in b
.
Upvotes: 1