Programmatically positioning a tag on an image


I want to create some tags onto an image.

This example comes from the manual (just to prove I have looked)
Tag/N=text3/F=0/A=RB/X=-0.80/Y=4.71 bottom, 13040000000, "Dinosaurs ruled"

Notice the location number: 13040000000 is explicitly defined
TagLocation = 13040000000

If it where in a variable and I did a print variable command the result would be
print taglocation

So if i used a variable to contain the location
Tag/N=text3/F=0/A=RB/X=-0.80/Y=4.71 bottom, Taglocation, "Dinosaurs ruled"
where Taglocation = 13040000000

I would not get the same result in the location because 1.304e+10 instead of 13040000000 is used.

How do I get around this?
I don't understand your problem.

First of all, I executed all of the code below, which is the example code in the manual that you are also using:

Make/O jack=sin(x/8)
SetScale x,0,14e9,"y" jack
Display jack
Label bottom "\\u#2 "                       // turn off default axis label
ModifyGraph axOffset(bottom)=1.16667        // make room for tag (manual adustment)
Tag/N=text0/F=0/A=MT/X=0.20/Y=-4.29/L=0 bottom, Nan, "\\JCTime (\\U)\rGratuitous 2nd line"

// now a few "important location" tags...
Tag/N=text1/F=0/A=LB/X=1.20/Y=3.00 bottom, 0, "Big Bang"
Tag/N=text2/F=0/A=MB/X=0.00/Y=2.86 bottom, 8000000000, "Earth formed"
Tag/N=text3/F=0/A=RB/X=-0.80/Y=4.71 bottom, 13040000000, "Dinosaurs ruled"

I then executed the following code:
variable/g taglocation=13040000000
Tag/N=text4/F=0/A=RB/X=-1.80/Y=8.71 bottom, taglocation, "Taglocation is a variable"

The result is that I get another tag, which points to the same point on the axis as does the "Dinosaurs ruled" tag.

You said you are dealing with an image. You might have missed this part of the command help for Tag (emphasis mine):

xAttach is the X value of the point on the trace to which the tag is to be attached. For a multidimensional image, it is the linear index into the matrix array. For an axis, xAttach can be the X or Y point depending on the axis to which the tag is attached; specifying NaN for xAttach will center the tag on the axis.

Given that 1.3e10 is more points than is possible to have in a wave, I think that you need to use x2pnt() and use the output of that function as the xAttach parameter.

I figured out my error/confusion.

I was calculating the point of the image for the tag to mark and I can enter/use that in the dialog box directly. When I call it I have to convert that point value back to "x Value". I use quotes because it is not really a pure x value, but rather the point value *X scaling.

Now it works as expected.

Mea culpa, though it is not the most straight forward way of implementing it. Perhaps you could implement a /P flag where the point value is used or better yet for images a {x position,y position} value. That way I could pass the position directly such as from hcsr(A) and Vcsr(A).
I spoke too soon.

I have an image that is scaled in x and y with offsets

Row: Offset 45 delta 0.012
Column: Offset -39 Delta 0.012

If I have a location defined by a pcsr(A),qcsr(a) how do I translate that location to the value used in the tag command?
hegedus wrote:
I spoke too soon.
If I have a location defined by a pcsr(A),qcsr(a) how do I translate that location to the value used in the tag command?

Should be:
wavePoint = (qcsr(A) * DimSize(waveName, 0)) + pcsr(A)