[Python] To plot variable number of plots with variable number of graphs from Pandas grouped...

Discussão em 'Python' iniciado por Stack, Fevereiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I've been dealing with Python for the last few months and it still a little bit irritate me :)

    But hope someone can explain how to plot some subplots from dataframe grouped by 2 columns using Matplotlib. Or give a link where I can find the information about this.

    There is the example of dataframe:

    name N coeff X1 Y1
    0 F2 F2_1 1 0 0.56451
    1 F2 F2_1 5 0 0.45005
    2 F2 F2_2 1 25 0.53641
    3 F2 F2_2 5 25 0.53641
    4 F2 F2_3 1 55 0.45067
    5 F2 F2_3 5 55 0.38828
    6 F2 F2_4 1 85 0.33279
    7 F2 F2_4 5 85 0.35315
    8 F2 F2_5 1 95 0.2756
    9 F2 F2_5 5 95 0.32571
    10 F2 F2_6 1 120 0.159
    11 F2 F2_6 5 120 0.27583
    12 F2 F2_7 1 150 0.05648
    13 F2 F2_7 5 150 0.21128
    14 F3 F3_1 1 0 0.42757
    15 F3 F3_1 5 0 0.32409
    16 F3 F3_2 1 25 0.36033
    17 F3 F3_2 5 25 0.2701
    18 F3 F3_3 1 55 0.2161
    19 F3 F3_3 5 55 0.17014
    20 F3 F3_4 1 85 0.08191
    21 F3 F3_4 5 85 0.10512
    22 F3 F3_5 1 95 0.04468
    23 F3 F3_5 5 95 0.09686
    24 F3 F3_6 1 120 0.07025
    25 F3 F3_6 5 120 0.033
    26 F3 F3_7 1 150 0.10689
    27 F3 F3_7 5 150 0.01334

    I group it by columns Name and Coeff and need to plot sublots for every Name with graphs for every Coeff. In this case it has to be 2 subplots for "F2" and "F3" with 2 graphs for coeff 1 and 5.

    There is no problem when I group it by 1 column. I don't understand how it works with grouping by some columns

    Continue reading...

Compartilhe esta Página