【ModifyGragh】 does not work on my box plot

Hello:

I am using procedure to do a box plot. But when I carried out the order, the error happened:While executing Modifygraph, the following error occurred: trace is not on graph. Also, the graph is wrong, although all waves had been loaded in the graph.

I do not know how to solve this problem.

I guess it may associate with that I use [wave = $("")] and when [Modifygraph] execute, it can not find the wave.

It is the main function:

Function Diurnal_distrib(timeline,data,p1,p2,p3,p4,p5,wName)
wave timeline, data
variable p1,p2,p3,p4,p5

string wName
string ListOfPercentiles =num2str(p1)+";"+num2str(p2)+";"+num2str(p3)+";"+num2str(p4)+";"+num2str(p5)

Make/O/N=24 $("W_p1"+wName),$("W_p2"+wName),$("W_p3"+wName),$("W_p4"+wName),$("W_p5"+wName),$("avera"+wName)
Wave W_p1=$("W_p1"+wName),W_p2=$("W_p2"+wName),W_p3=$("W_p3"+wName),W_p4=$("W_p4"+wName),W_p5=$("W_p5"+wName),avera=$("avera"+wName)
//Make/O/N=24 W_p1,W_p2,W_p3,W_p4,W_p5,avera
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 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]
avera[i]=mean(temp)
endfor

Display W_p5,W_p4,W_p3,W_p2,W_p1,avera vs txtWave
print "yes no"
ModifyGraph mode(avera)=3,marker(avera)=16,hbFill(avera)=0,msize(avera)=3
print "yes"
ModifyGraph tomode(W_p1)=1, 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)=(65535,65535,65535),useBarStrokeRGB(W_p4)=1,rgb(W_p3)=(65535,65535,65535),useBarStrokeRGB(W_p3)=1

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
diurnal disturb.ipf (2.73 KB)
You need to use <igor> and </igor> tags so that your Igor code is readable in this forum. See http://www.igorexchange.com/node/3221 for details.

The reason for the error is that you are confusing wave references (e.g., w_p1) with trace names. Execute this for an explanation:
DisplayHelpTopic "Programming With Trace Names"
hrodstein wrote:
You need to use <igor> and </igor> tags so that your Igor code is readable in this forum. See http://www.igorexchange.com/node/3221 for details.

The reason for the error is that you are confusing wave references (e.g., w_p1) with trace names. Execute this for an explanation:
DisplayHelpTopic "Programming With Trace Names"


Thanks for your help. Now I can use "modifygraph" to change the trace. Now I have some new problems. I use the hour as txt format displaying on my graph and I make the "txtWave" by "Make" operation. However it looks to crowed on the axis and I can not modify it(for example, I cannot set major ticks, minor ticks or tick increment ). Then I make a number wave to display hours of day. Howvever, two new problems exist. Firstly, it seems that the middle of bars on the gragh"diurnal_by_number" were not aligned with the axis number precisely. Secondly, I can not modify the "category gap" and "bar gap" on the "axis" of "modify axis" dialog any more and all bars were lined together, which I want to change.
Function Diurnal_distrib(timeline,data,p1,p2,p3,p4,p5,wName)
    wave timeline, data
    variable p1,p2,p3,p4,p5
 
    string wName
    string ListOfPercentiles =num2str(p1)+";"+num2str(p2)+";"+num2str(p3)+";"+num2str(p4)+";"+num2str(p5)
 
    Make/O/N=24 $("W_p1"+wName),$("W_p2"+wName),$("W_p3"+wName),$("W_p4"+wName),$("W_p5"+wName),$("avera"+wName)
    Wave W_p1=$("W_p1"+wName),W_p2=$("W_p2"+wName),W_p3=$("W_p3"+wName),W_p4=$("W_p4"+wName),W_p5=$("W_p5"+wName),avera=$("avera"+wName)
    //Make/O/N=24 W_p1,W_p2,W_p3,W_p4,W_p5,avera
    Make/O/N=24 temp_hour=p
    Make/O/N=(numpnts(data)) hour_data
//  Make/O/T/N=24 txtWave
//  txtWave=num2str(p)
    Make/O/N=24 txtWave
    txtWave=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]
        avera[i]=mean(temp)
    endfor
 
    Display W_p5,W_p4,W_p3,W_p2,W_p1,avera vs txtWave
    print "yes no"
    ModifyGraph mode($("avera"+wName))=3,marker($("avera"+wName))=16,hbFill($("avera"+wName))=0,msize($("avera"+wName))=3
    print "yes"
    ModifyGraph tomode($("W_p1"+wName))=1, mode($("W_p1"+wName))=3, marker($("W_p1"+wName))=9,rgb($("W_p1"+wName))=(0,0,0)
    ModifyGraph mode($("W_p2"+wName))=1,toMode($("W_p2"+wName))=1,rgb($("W_p2"+wName))=(0,0,0)
    Modifygraph mode($("W_p3"+wName))=5,toMode($("W_p3"+wName))=1,rgb($("W_p3"+wName))=(65535,65535,65535),useBarStrokeRGB($("W_p3"+wName))=1
    Modifygraph mode($("W_p4"+wName))=5,toMode($("W_p4"+wName))=1,rgb($("W_p4"+wName))=(65535,65535,65535),useBarStrokeRGB($("W_p4"+wName))=1
    ModifyGraph mode($("W_p5"+wName))=8,marker($("W_p5"+wName))=9,rgb($("W_p5"+wName))=(0,0,0),toMode($("W_p5"+wName))=1



// modify the appearance of the graph
    ModifyGraph tick(bottom)=4,mirror=2,font="Arial",catGap(bottom)=0.25
    ModifyGraph barGap(bottom)=0.25
    Label left "Conc(礸 m\\S-3\\M)"
    Label bottom "Hour of Day"
    SetAxis/A/E=1 left    
    ModifyGraph lblLatPos=0
    ModifyGraph lblPosMode(bottom)=2,lblMargin(bottom)=15
    ModifyGraph lblPosMode(left)=1,lblMargin(left)=10
    ModifyGraph margin(left)=57,margin(bottom)=57,margin(top)=28,margin(right)=28;DelayUpdate
    ModifyGraph width=226.772,height=170.079
    TextBox/C/N=text0/F=0/A=LT/E=2 "\\F'Arial'\\Z14NO\\B3"
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

I post the two pictures which x-axis were txt and number respectively. Would you please help me solve the problems?
Thank you again.
Eric
The best way to get help on a complicated question like this is to create a greatly simplified example that shows the problem and post an Igor experiment containing the example so that others can understand the problem and try various solutions.

Rather than spending lots of time creating box plots with procedure code, you probably should try the Igor 8 beta. Box plots are built in in Igor 8.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com