Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Multiple scatter plots on one plot

I am having two audio files and I am taking their 1D convolution. The output has 3 points for each audio file. I wanted to plot the outputs of both the files on the scatter plot but I am able to plot just the last output. Can anybody please help me to plot both the outputs?

path = 'C:/Users/....'
for filename in glob.glob(os.path.join(path, '*.wav')):
    sample_rate,audio = wavfile.read(filename)
    x = audio
    z = x.reshape(1,audio.shape[0],1)
    z = tf.constant(z, dtype=tf.float32)
    print(x.shape)
    print(audio.shape[0])
    y = tf.keras.layers.Conv1D(1, 44095, activation='relu', input_shape=(1,audio.shape[0],1))(z)
    y=y.numpy()

    print(y)
    aa=y.reshape(-1)
    
    fig = plt.figure()

    ax = fig.add_subplot(111, projection='3d')
    ax.scatter(np.arange(3), aa, color = 'crimson')
plt.show() 

The plot that I am getting is:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You don’t really need 3d for your case, as you have index + feature, so you only need 2 dimensions for each point, you can use the default 2d plotting context and use:

    # in the loop
    plt.scatter(np.arange(3), aa, color = 'crimson')
# outside the loop
plt.show()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading