0

I am trying to display multiple plots with different shapes. However, I got an error message ValueError: x and y must have same first dimension, but have shapes (10000,) and (5000,)

Actually, they have different shapes and must be displayed in different plots.

Expectation: Display 2 charts for signals and resampled_signal

Here is my code:

time = np.arange(signals.size) / fs_target
fig1 = plt.figure()
fig2 = plt.figure()

ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111)

ax1.plot(time, signals, color='blue', marker='o')
ax2.plot(time, resampled_signal, color='blue', marker='o')
st.pyplot(plt)

I followed the idea in python - pyplot plotting with different shapes - Stack Overflow, but the error will come when the st.pyplot(plt) is executed.

Huy DQ
  • 121
  • 1
  • 11
  • The size of your `resampled_signal` should have the same size with your `time`. – ferdy May 02 '22 at 13:21
  • Thanks for your comment. Regarding the business, the time remains stable but the signal is recalculated based on the sample rate. That leads to the different lengths (number of samples). That's why I have the `resampled_signal` and `signals` at the same time, but different length. And I tried to show the difference by displaying the plots – Huy DQ May 02 '22 at 15:58
  • What is the length or size of your `resampled_signal` and what is the length or size of your `time`? – ferdy May 03 '22 at 00:31

0 Answers0