Appending Values (string and variable) to a Table

After I have generated ratio value from lambda, I would like to append the values to a table for category plotting. I found a similar thread in IgorExchange, and
I successfully added the code into mine, but I would like to also add a text column corresponding to the value. How do I add another column to the table? If there is a better way to perform category plotting from the graph without use of table, the suggestion is also welcomed.
(currently, I used the function print to display the value of "tracename" and "ratioValue", then perform copy-past function to the table for category plotting. )

Menu "Ratiometric",dynamic
    TraceNameList ("",";",1), donor_acceptor()
"Ratio all",   donor_acceptorAll()
End


Function donor_acceptor()
    variable donor
    variable acceptor
    prompt acceptor,"Acceptor peak"
    Prompt donor,"Donor peak"
    Doprompt "Enter values", acceptor,donor
    if (V_flag == 0)
        ratiometric(donor, acceptor)
    endif
end

Function ratiometric(donor,acceptor)
variable donor,acceptor
    GetLastUserMenuInfo     // sets S_value, V_value, etc.
    ratiometric_value(S_value,donor,acceptor)
end

Function ratiometric_value(tracename,donor,acceptor)
string tracename
variable donor,acceptor
wave w= traceNametowaveRef("",traceName)
    wavestats/q w
    variable xPeak = V_maxloc
    VARIABLE ratioValue = w(acceptor)/w(donor)  //scale value indexing
  //   VARIABLE ratioValue = w[acceptor]/w[donor]   // point value indexing  
    String TextItRatio
    sprintf TextItRatio, "\\Z09 \\K(0,65280,0)\\ON  \rRatio=%g",ratioValue
        Tag /F=2/S=3/A=MT/B=(0,0,0)  $tracename,xPeak, TextItRatio

//Appending values to a table, found in igorexchange.com/node/4857

Wave/Z/D ratioValueTable    // Look for ratioValue wave in current data folder
if (!WaveExists(ratioValueTable))
    Make/O/D/N=0 ratioValueTable
endif
Wave ratioValueTable
Variable numPoints = numpnts(ratioValueTable)
ratioValueTable[numPoints] = {ratioValue}   // Add new point to integrals

print tracename, ratioValue

End
 
Function donor_acceptorAll()
    variable donor
    variable acceptor
    variable ratioValue
    prompt acceptor,"Acceptor peak"
    Prompt donor,"Donor peak"
    Doprompt "Enter values", acceptor,donor
    if (V_flag == 0)
        ratiometricall(donor, acceptor)
    endif
end
Function ratiometricall(donor,acceptor)
variable donor,acceptor
variable ratioValue
    String list = TraceNameList("", ";", 1)
    String tracename

    Variable index = 0
    do
        traceName = StringFromList(index, list)
        if (strlen(traceName) == 0)
            break // No more traces.
        endif
     ratiometric_value(tracename,donor,acceptor)
        index += 1
    while(1)
   
wave ratioValueTable
edit ratioValueTable       
end

Thank you!
I don't fully get your request.
Do you want a second column containing the ratios? That would work with
Edit LabelWave, ValueWave
or
Edit LabelWave
AppendToTable ValueWave


If you want to concatenate both properties use num2str and "+"
Labels=LabelWave+" "+num2str(ValueWave)

For testing:
Make /N=2 /T LabelWave={"test1", "test2"}, Labels
Make /N=2 ValueWave={42,95}


Hope it covers your concern,
HJ
About the "make" operation, how do I input the variables and string to the make operation? I have a set of variables and strings from a plot.
I tried the following and I only get the first set of data.

string tracename
variable ratiovalue
.....

Make /N=2 /T NameofTrace={traceName}
Make /N=2 ratioTabe={ratiovalue}
edit nameofTrace,ratioTable

Any suggestions?

Thank you!

HJDrescher wrote:
I don't fully get your request.
Do you want a second column containing the ratios? That would work with
Edit LabelWave, ValueWave
or
Edit LabelWave
AppendToTable ValueWave


If you want to concatenate both properties use num2str and "+"
Labels=LabelWave+" "+num2str(ValueWave)

For testing:
Make /N=2 /T LabelWave={"test1", "test2"}, Labels
Make /N=2 ValueWave={42,95}


Hope it covers your concern,
HJ

Note the comma in the curly brackets in my test example. I separates entries. You also get a wave with one row although /N=2 creates a wave with 2 rows: "{...}" overwrites the original size.

print tracename, ratioValue make me think you want one string for one pair of tracename and ratio combined in one text label.

create a text wave (Make /T) called "ratioValueLables" and change
ratioValueTable[numPoints] = {ratioValue}
to
ratioValueTable[numPoints] = {ratioValue}
ratioValueLables[numPoints] = {tracename +" " + num2str(ratioValue)}

There are more elegant ways to do something like this, but it is still not clear what you are about to do.
HJ
Thank you very much, I cannot make it to work. Here, I attached a figure to show you what I want to do.
A. Obtaining ratio by B/A
B. Making table Name(a) <---> Ratio(a)
C. Plotting with category

I can obtain ratio value (ratioVAlue) and their name (tracename), but I struggled to plot them with one or two steps.

Can you point me to that direction?

Thank you!



HJDrescher wrote:
Note the comma in the curly brackets in my test example. I separates entries. You also get a wave with one row although /N=2 creates a wave with 2 rows: "{...}" overwrites the original size.

print tracename, ratioValue make me think you want one string for one pair of tracename and ratio combined in one text label.

create a text wave (Make /T) called "ratioValueLables" and change
ratioValueTable[numPoints] = {ratioValue}
to
ratioValueTable[numPoints] = {ratioValue}
ratioValueLables[numPoints] = {tracename +" " + num2str(ratioValue)}

There are more elegant ways to do something like this, but it is still not clear what you are about to do.
HJ

thestory.png
Try (in the command line)
duplicate /O /T Name LabelText
LabelText =Name+"\r"+num2str(Ratio)
Display Ratio vs LabelText

but I'm still not sure if this is what you want. Maybe you also want to have a look at
displayhelptopic "Tag"

HJ
That helps, but I want to do more than that.

The detail:
First, what I want to do is to create a functions to measure a ratio from a lambda plot (a raw data format : intensity vs. wavelength).
To do this, I have to measure the ratio between lambda position at 580nm / 483 nm.
After obtaining the ratio (RatioValue in this case) by presenting in the same plot with tag operation.

Then I would like to create the bar chart with category plot. This is the step I struggle to transfer the values into category plot automatically.

Ultimately, I want to build a function to do the task with one step.
First, obtaining ratio value from raw lambda data
Second, automatically plot into category bar chart.

Does it clear to you? I really appreciate your helps.




HJDrescher wrote:
Try (in the command line)
duplicate /O /T Name LabelText
LabelText =Name+"\r"+num2str(Ratio)
Display Ratio vs LabelText

but I'm still not sure if this is what you want. Maybe you also want to have a look at
displayhelptopic "Tag"

HJ

You can simply copy this fragment into your code (with the WAVE and WAVE /T references) at the end of your procedure generating the Name and Ratio waves (the display command is most likely to be omitted or at least it is necessary to check if this window is already displayed) to update your categories.
It is ok that the LabelText wave gets overwritten each time.

HJ

Good idea! i did not see that. Thank you again!
HJDrescher wrote:
You can simply copy this fragment into your code (with the WAVE and WAVE /T references) at the end of your procedure generating the Name and Ratio waves (the display command is most likely to be omitted or at least it is necessary to check if this window is already displayed) to update your categories.
It is ok that the LabelText wave gets overwritten each time.

HJ