0

I have a dataset where each row plots an ECG, with 50k rows, 181 columns and has 4 classes, represented in the last column (0, 1, 2, 3).

So, I need to "convert" each row for images plotting each one, but I only know to separate according to the values of the last column and plot each one.

Plotting this manually and will take a lot of time to finish,is there a way to plot a considered number of images for each class?

I'm using Python for this work.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Please provide enough code so others can better understand or reproduce the problem. – Community Apr 14 '22 at 03:39
  • Welcome to SO. Please read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a minimal, complete, and reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), then edit your question accordingly. You may also be interested in reading [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – Mr. T Apr 14 '22 at 18:43

1 Answers1

0

You can do this by using the method subplots() using Matplotlib. Here is an example using a list of lists for the data and then indexing for the axis. Using a pandas pandas you can achieve the same output itering through the columns in the for loop.

Note; if the figure has more the 1 column of axis you have do index it with 2 brackets [col][row]

y_vals = [0, 2, 5, 6, 6, 8]
x_vals = [2 , 4, 6, 8, 10, 12]
x_data = [x_vals for x in range(4)]
y_data = [y_vals for y in range(4)]

fig, ax = plt.subplots(4, figsize=(4, 8))
 
for i in range(4):
    ax[i].plot(x_data[i], y_data[i])
    
fig, ax2 = plt.subplots(4,4, figsize=(8, 4))

for i in range(4):
    for j in range(4):
        ax2[i][j].plot(x_data[i], y_data[i])

enter image description here