0

I am new to Python and I am trying to make a subplot that will stack all subplots in a single column. With the current code I have, it will make the subplots in the correct position, but all in different figure windows. How can I keep all the subplots in one window during this loop (python)? Below is the code that I currently have:

    while i <= len(row_number)-1:
        i = int(i)
        t = int((len(row_number)))
        figure, axes = plt.subplots(nrows=t)
        g = data.iloc[:, p]
        axes[i].plot(g)
        axes[i].set_title('Muscle {}'.format(muscle_list[i]))
        axes[i].set_xlabel('Number of Frames')
        axes[i].set_ylabel('Voltage')
        figure.suptitle('EMG of Muscles {}'.format(muscle_list))
        i = i + 1
    plt.show()
  • Python doesn't have any builtin plotting tools. What library are you using to make the plots? matplotlib? – Brian61354270 Apr 26 '21 at 22:51
  • Follow the `subplot` instructions in the attached duplicate. Simply throw the repetitive code into a loop. – Prune Apr 26 '21 at 22:51
  • wouldn't be simpler `for i in range(row_number)` ? It doesn't need `i = i + 1` . And it seems `i` is `integer` - so you don't have to use `i = int(i)` . OR maybe you should do it without `i` - simply `for item in muscle_list:` – furas Apr 27 '21 at 00:44

0 Answers0