I have two numpy arrays (a and b) with shape (16, 850) each. I'm displaying them row by row, e.g.
plt.figure()
plt.plot(a[0], b[0])
plt.plot(a[1], b[1])
plt.plot(a[2], b[2])
...
plt.show()
Should I have to use a for loop to do it in a more pythonic way?
From matplotlib we use the specific function i.e. pyplot(), which is used to plot two-dimensional data. Different functions used are explained below: np. arange(start, end): This function returns equally spaced values from the interval [start, end).
You can pass a multi-dimensional array to plot
and each column will be created as a separate plot object. We transpose both inputs so that it will plot each row separately.
a = np.random.rand(16, 850)
b = np.random.rand(16, 850)
plt.plot(a.T, b.T)
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With