Box and Whisker Plot of selected data

Hello all,

I am a basic user of Igor, but unfortunately I have no skill in programing.

I use Igor to calculate percentile and make box and whisker plot for the whole dataset. But, I was wondering if is possible I use the "Wave Percentile" to calculate percentile for an interval. For instance, as in data attached, can I calculate de percentile for data at each day, I mean, percentile for data of 24h, for month, etc..


Many thanks

Thiago
2012.txt (163.04 KB)
Hi Thiago,

Yes, you can use the fWavePercentile function, as long as you select the data that you want. The Extract function may be your best friend.
Below is a code to calculate the hourly distribution of a dataset (for a box and whisker plot, p1 to p5 should be 10, 25, 50, 75 and 90)

Hope this helps a bit
Cheers
J-E


Function Diurnal_distrib(timeline,data,p1,p2,p3,p4,p5)
    wave timeline, data
    variable p1,p2,p3,p4,p5
   
    string ListOfPercentiles=num2str(p1)+";"+num2str(p2)+";"+num2str(p3)+";"+num2str(p4)+";"+num2str(p5)
   
    Make/O/N=24 W_p1,W_p2,W_p3,W_p4,W_p5
    Make/O/N=24 temp_hour=p
    Make/O/N=(numpnts(data)) hour_data
    Make/O/T/N=24 txtWave
    txtWave=num2str(p)
   
    variable i
    for (i=0;i<numpnts(data);i+=1)
        hour_data[i]=determinehour(timeline[i])
    endfor
   
    string p1_str="temp_p_"+num2str(p1)
    string p2_str="temp_p_"+num2str(p2)
    string p3_str="temp_p_"+num2str(p3)
    string p4_str="temp_p_"+num2str(p4)
    string p5_str="temp_p_"+num2str(p5)
   
    for (i=0;i<24;i+=1)
        Extract/O data,temp,hour_data==i
        WaveTransform zapNaNs, temp
        fWavePercentile("temp", ListOfPercentiles, "temp_p", 0,     0, 0)
        wave temp_p1=$p1_str
        wave temp_p2=$p2_str
        wave temp_p3=$p3_str
        wave temp_p4=$p4_str
        wave temp_p5=$p5_str
        W_p1[i]=temp_p1[0]
        W_p2[i]=temp_p2[0]
        W_p3[i]=temp_p3[0]
        W_p4[i]=temp_p4[0]
        W_p5[i]=temp_p5[0]
    endfor

    Display W_p5,W_p4,W_p3,W_p2,W_p1 vs txtWave
    ModifyGraph mode(W_p1)=3,marker(W_p1)=9,rgb(W_p1)=(0,0,0),mode(W_p2)=1
    ModifyGraph toMode(W_p2)=1,rgb(W_p2)=(0,0,0),toMode(W_p3)=1,toMode(W_p4)=1
    ModifyGraph mode(W_p5)=8,marker(W_p5)=9,rgb(W_p5)=(0,0,0)
    ModifyGraph toMode(W_p5)=1
    ModifyGraph rgb(W_p4)=(43520,43520,43520),rgb(W_p3)=(43520,43520,43520)
   
End Function

Function Determinehour(dt)
    Variable dt                 // Input date/time value
    Variable time = mod(dt, 24*60*60)   // Get the time component of the date/time
    return trunc(time/(60*60))
End


On your dataset, it gives the enclosed image.
2012_diurnal.png (12.19 KB)
J-E Petit wrote:
Hi Thiago,

Yes, you can use the fWavePercentile function, as long as you select the data that you want. The Extract function may be your best friend.
Below is a code to calculate the hourly distribution of a dataset (for a box and whisker plot, p1 to p5 should be 10, 25, 50, 75 and 90)

Hope this helps a bit
Cheers
J-E


Function Diurnal_distrib(timeline,data,p1,p2,p3,p4,p5)
    wave timeline, data
    variable p1,p2,p3,p4,p5
   
    string ListOfPercentiles=num2str(p1)+";"+num2str(p2)+";"+num2str(p3)+";"+num2str(p4)+";"+num2str(p5)
   
    Make/O/N=24 W_p1,W_p2,W_p3,W_p4,W_p5
    Make/O/N=24 temp_hour=p
    Make/O/N=(numpnts(data)) hour_data
    Make/O/T/N=24 txtWave
    txtWave=num2str(p)
   
    variable i
    for (i=0;i<numpnts(data);i+=1)
        hour_data[i]=determinehour(timeline[i])
    endfor
   
    string p1_str="temp_p_"+num2str(p1)
    string p2_str="temp_p_"+num2str(p2)
    string p3_str="temp_p_"+num2str(p3)
    string p4_str="temp_p_"+num2str(p4)
    string p5_str="temp_p_"+num2str(p5)
   
    for (i=0;i<24;i+=1)
        Extract/O data,temp,hour_data==i
        WaveTransform zapNaNs, temp
        fWavePercentile("temp", ListOfPercentiles, "temp_p", 0,     0, 0)
        wave temp_p1=$p1_str
        wave temp_p2=$p2_str
        wave temp_p3=$p3_str
        wave temp_p4=$p4_str
        wave temp_p5=$p5_str
        W_p1[i]=temp_p1[0]
        W_p2[i]=temp_p2[0]
        W_p3[i]=temp_p3[0]
        W_p4[i]=temp_p4[0]
        W_p5[i]=temp_p5[0]
    endfor

    Display W_p5,W_p4,W_p3,W_p2,W_p1 vs txtWave
    ModifyGraph mode(W_p1)=3,marker(W_p1)=9,rgb(W_p1)=(0,0,0),mode(W_p2)=1
    ModifyGraph toMode(W_p2)=1,rgb(W_p2)=(0,0,0),toMode(W_p3)=1,toMode(W_p4)=1
    ModifyGraph mode(W_p5)=8,marker(W_p5)=9,rgb(W_p5)=(0,0,0)
    ModifyGraph toMode(W_p5)=1
    ModifyGraph rgb(W_p4)=(43520,43520,43520),rgb(W_p3)=(43520,43520,43520)
   
End Function

Function Determinehour(dt)
    Variable dt                 // Input date/time value
    Variable time = mod(dt, 24*60*60)   // Get the time component of the date/time
    return trunc(time/(60*60))
End


On your dataset, it gives the enclosed image.



Dear J-E, many thanks for your reply.

I am trying to run the function Diurnal_distrib(timeline,data,p1,p2,p3,p4,p5), but the sintax error appears: expected wave name. Should I create timeline and data wave before? This is not clear for me...
This diurnal distribution will be very useful for me, but I was thinking about the calculation of percentile for each day, as in figure attached. I did this manually, and this took me many efforts. What I should change in this procedure?

Thank you again.
Thiago

Graph0_11.png (10.27 KB) Graph0_11.png (10.27 KB) Graph0_11.png (10.27 KB)