How to display multiple plots with different shapes?

Hi everyone,

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.

Hi @qhi -

This isn’t a Streamlit issue per se, but rather than you’re trying to assign too many points to too few time values. How you re-sample for your problem domain isn’t something I can tell you, but taking avg/min/max per time slice is one of many ways to handle that issue, so that you have 5000 times and 5000 values to plot.

Best,
Randy