overlay lines in plot grouped by multiple variables in multiple columns

13 views Asked by At

this is an example of my df:

ref period cum dummy
1     1     0.1   0
1     1     0.2   0
1     2     0.1   1
1     2     0.15  0
1     3     0.14  0
1     3     0.13  0
1     4     0.12  0
1     4     0.11  0
2     1     0.10  0
2     1     0.09  0 
2     2     0.11  1
2     2     0.12  0
2     3     0.15  0
2     3     0.16  0
2     4     0.17  0
2     4     0.18  0

in reality, my ref goes up to 30, my period goes from 1 to 5, and my ref is not always the same length, that is, the 1 might be 5398 rows, the 2 might be 6543 rows, etc etc, but more or less they are the same.

I want to plot on the same chart, a line for each ref, where the x is the period and the y is the cum, and in the midle there is a vertical line whihc is the dummy. However, the x, which is the period, cannot be just 4 point but it has to be a tick for every row, like this:

ref period 
    1     1.1     
    1     1.2     
    1     1.3     
    1     2.1     
    1     2.2     
    1     3.1     
    1     4.1     
    1     4.2     
    2     1.1     
    2     1.2    
    2     2.1    
    2     2.2    
    2     3.1     
    2     3.2     
    2     4.1     
    2     4.2
    2     4.3     
    2     4.4     


 
0

There are 0 answers