Cursor "z" value from a regular xy plot including f(z)
ajleenheer
How can I quickly see the exact "z" value from a given point when using this format? I can put the cursor on a point, and the info bar shows x and y info but nothing about the z wave I've assigned in f(z). Currently I have to show a table with the Z wave and scroll to the point indicated by the cursor. Ideally I'd like a way to do this just using the GUI, but I'd be open to some procedure especially if I don't have to run it manually every time. Thanks.
w_y
vsw_x
trace a second time, but this time around you can use the numerical wavew_z
instead of a marker.You can also offset the position of the text-markers (appended trace) by some number depending on the scale. (
ModifyGraph offset(w_y)={4,0})
andModifyGraph muloffset(w_y)={1.2,1.2}
are commands you can take a look).Attached I have put an example. The example offsets in the bottom axis only.
best,
_sk
June 23, 2017 at 12:42 am - Permalink
Might be a little work though. Do you need this information for a single window or several windows simultaneously (one global panel or one panel per graph) ?
HJ
June 23, 2017 at 01:14 am - Permalink
In the meantime, use this function in a tag:
Function/S fofztagZvalue(string tracename)
String zcolorinfo = WMGetRECREATIONInfoByKey("zColor(x)", traceinfo("", "junk", 0))
String wavepath = StringFromList(0, zcolorinfo, ",")
wavepath = wavepath[1,inf]
Wave zwave = $wavepath
return num2str(zwave[tagval(0)])
end
This function needs to be called from dynamic text in a tag attached to the trace in question. Here is tag text I used to get a very simply printout of the Z value:
That just shows the number in the tag. You may wish to enhance it somewhat. Also, the given function always returns 6-digit precision. You might want to use sprintf to give you more control over the precision and formatting of the returned text.
You can reposition the tag on any data point by holding the option (alt) key down while dragging the tag onto a new point.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 23, 2017 at 08:45 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 23, 2017 at 08:46 am - Permalink
if (strlen(graphname) == 0)
graphname = WinName(0,1)
endif
string tagname = UniqueName("fofzTag", 14, 0, graphname)
Tag/C/N=$tagname/L=1 $tracename, pnum, "\\{fofztagZvalue(\"" + tracename + "\")}"
end
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 23, 2017 at 08:58 am - Permalink
Although I don't want all the values displayed on the graph (too messy for most of my graphs), this gave me an idea for a workaround. I can append the Z wave vs. the X wave and hide it. Then I can put both the A and B cursors on the point interest, then switch the B cursor to the hidden Z wave such that its value at least displays in the info box. Kind of a pain, but it's at least a temporary solution.
John, I couldn't get your procedures to work. It seemed that the line
WMGetRECREATIONInfoByKey("zColor(y)",traceinfo("","junk",0))
was returning an empty string, and I'm not sure how to dig into that particular function.A dedicated panel for each graph would be fine for my purpose, especially if you could create or hide it at will. Usually my graphs only contain one trace, if that would simplify anything. Thanks for the help so far.
June 26, 2017 at 07:49 am - Permalink
Function/S fofztagZvalue(string tracename)
String zcolorinfo = WMGetRECREATIONInfoByKey("zColor(x)", traceinfo("", tracename, 0))
String wavepath = StringFromList(0, zcolorinfo, ",")
wavepath = wavepath[1,inf]
Wave zwave = $wavepath
return num2str(zwave[tagval(0)])
end
And the text for the tag would be
My second function works correctly as long as you use the actual trace name, and not "junk". My testing worked, of course, because I didn't change the trace name between copying info from the command line and using that info to compose my function.
John "Red Faced" Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 26, 2017 at 09:00 am - Permalink
The main function is
InstallDataPanelHook(WindowName, MaxCursors, w_x, w_y, w_d)
with
WindowName: The name of the graph or "" for the topmost one
MaxCursors: The intended maximum number of used cursors
w_x, w_y, w_z: Wave references to the three waves containing the x, y, data triplets
No warranty!
Have fun
HJ
PS: If there are at least two cursors used, the differences between the properties of cursor A and cursor B are displayed as well
PPS: If you need a version that works on 2D waves, just leave a message
June 26, 2017 at 10:21 am - Permalink
June 26, 2017 at 12:54 pm - Permalink
Without knowledge of the detailed data structure, such things might happen. However, "" as a value for WindowName was working on my sample experiment if it had a valid top most graph in it... ('valid' is probably the crucial point)
Cheers,
HJ
PS: Found the mistake: "" as an alias for windowname is in the wrong function... --> pre-beta :-)
June 26, 2017 at 04:26 pm - Permalink
If you want to make it real nice this is another story all together, but I understood you wanted something that will do the job fast.
There are so many ways of doing what you want, but the best way would have to be made by you.
best,
_sk
This is an example. You start by issuing
thunk_make_data()
in the command window. Then you hover over the point you want to find the value of and you press theV
key on your keyboard. Modify as you wish.string s_winname = "thunkdata"
dowindow $s_winname
if (v_flag)
dowindow/k $s_winname
endif
make/o/n=10 w_a = gnoise(10)
make/o/n=10 w_b = gnoise(10)
make/o/n=10 w_c = gnoise(10)
display/n=$s_winname/k=1 w_a vs w_b
ModifyGraph/w=$s_winname mode=3,marker=16,msize=5,useMrkStrokeRGB=1;DelayUpdate
ModifyGraph/w=$s_winname zColor(w_a)={w_c,*,*,Grays,0};DelayUpdate
ModifyGraph/w=$s_winname width={Aspect,1},height={Aspect,1};DelayUpdate
ModifyGraph/w=$s_winname mirror=2
setwindow $s_winname, hook(modified)=thunk_hook
end
function thunk_hook(s)
struct WMWinHookStruct& s
//print s.eventname
//print s.keycode
strswitch (s.eventname)
case "keyboard":
switch (s.keycode)
case 118:
// pressing the key V
string s_traceinfo = TraceFromPixel(s.mouseloc.h, s.mouseloc.v, "WINDOW:"+s.winname+";")
variable v_pt = str2num(stringbykey("HITPOINT", s_traceinfo))
wave w_c = root:w_c
wave w_a = root:w_a
wave w_b = root:w_b
//print s_traceinfo
if (numtype(v_pt) != 2)
print "f(z): ", w_c[v_pt]
tag/c/n=t1/b=3/f=2/s=3/v=1/X=10/Y=10 w_a, v_pt, num2str(w_c[v_pt])
endif
break
case 107:
tag/n=t1/k
break
endswitch
break
case "kill":
setwindow $(s.winname), hook(modified)=$""
break
endswitch
end
June 27, 2017 at 02:45 am - Permalink
struct WMWinHookStruct& s
strswitch (s.eventname)
case "mouseup":
wave w_c = root:w_c
wave w_a = root:w_a
wave w_b = root:w_b
string s_traceinfo = TraceFromPixel(s.mouseloc.h, s.mouseloc.v, "WINDOW:"+s.winname+";")
variable v_pt = str2num(stringbykey("HITPOINT", s_traceinfo))
if (numtype(v_pt) != 2)
//print "f(z): ", w_c[v_pt]
tag/c/n=t1/b=3/f=2/s=3/v=1/X=10/Y=10 w_a, v_pt, num2str(w_c[v_pt])
else
tag/n=t1/k
endif
break
case "kill":
setwindow $(s.winname), hook(modified)=$""
break
endswitch
end
best,
_sk
June 27, 2017 at 04:47 am - Permalink
Thanks for the suggestions, sk. I implemented them within HJDrescher's framework, and it all works together now. I like the simplicity of your solution but it doesn't seem to fit within Igor's GUI: the mouseup (click) functionality somewhat interferes with the ability to double-click on a trace to modify its appearance; any click creates/moves the tag. Is there a way to distinguish a double-click from a single click? And on the keyboard hook version to press "V", it works once, but Igor interprets the key press as the start of typing in the command window. Can that shift of window focus be overridden in the hook function?
I appreciate all the help. I'm pretty new at generating custom UI elements in Igor.
June 27, 2017 at 08:50 am - Permalink
For me the double click works when the hook is on the mouseup event.
And the keyboard hook works without focus stealing to the command window.
(Win7, IP6.37)
But above all, I am providing these as simple examples which you would have to accommodate to your work case.
Good luck with using Igor ;-)
best,
_sk
June 27, 2017 at 11:44 am - Permalink
Thanks for this function _sk. This was a good introduction to hooks for me. It might be useful to note that this works even if you haven't set the f(z) color option. It just pulls the z-value from a third specified wave. I did have to change the w_y wave variable into a string variable to get it to work, but this could be due to me using an older version of Igor.
I couldn't get it to work with a set of 2D data that I had plotted up because each curve has the same trace name. Is there some way around this?
August 7, 2019 at 11:40 am - Permalink