Use dimlabels in legend
BMangum
I understand that I can use a fake waterfall plot to do something like this, the problem is, I want the data crossing each other not offset.
I have been simply appending each column or row to a plot.
When I add a legend, the text of course is something like wave0, wave0 #1, wave0#2, etc.
Alternatively, what I am hoping to do is use dimlabels as legend strings.
Is there a convenient , "built-in" way to do such a thing?
I can store each wave separately in a folder and this becomes a non-issue.
However, I typically perform other various manipulations to the data where this becomes a nuisance.
Other than plotting, it is more convenient for my application to have the data in a 2d wave.
So again I ask, can dimlabels be used in a plot legend in some straightforward way?
Make/O/N=(3,128) test = sin(q/(8+p))
SetDimLabel 0, 0, FirstRow, test
SetDimLabel 0, 1, SecondRow, test
SetDimLabel 0, 2, ThirdRow, test
Display test[0][], test[1][], test[2][]
ModifyGraph rgb(test#0) = (65535, 0, 0)
ModifyGraph rgb(test#1) = (0, 65535, 0)
ModifyGraph rgb(test#2) = (0, 0, 65535)
Legend/C/N=text0/J/A=MC "\\s(test) \\{GetDimLabel(test,0,0)}\r\\s(test#1) \\{GetDimLabel(test,0,1)}\r\\s(test#2) \\{GetDimLabel(test,0,2)}"
End
December 16, 2013 at 03:37 pm - Permalink
If you've already got a routine to append columns or rows to graphs, you might consider the "trace name" keyword which allows you to assign a trace name to a wave (not the same as the wave name). More info available by issuing on the command line:
DisplayHelpTopic "Programming with Trace Names"
Working from the very nice previous example:
Make/O/N=(3,128) test = sin(q/(8+p))
Display test[0][]/TN=FirstRow, test[1][]/TN=SecondRow, test[2][]/TN=ThirdRow
ModifyGraph rgb(FirstRow) = (65535, 0, 0)
ModifyGraph rgb(SecondRow) = (0, 65535, 0)
ModifyGraph rgb(ThirdRow) = (0, 0, 65535)
Legend/C/N=text0/A=MC
End
December 28, 2013 at 09:33 am - Permalink
Thanks.
December 30, 2013 at 09:53 am - Permalink
Now that I have spent some effort into getting my nice legend, I want to add more traces, but I do not want the legend to auto update.
Any suggestions on how to do this programatically?
I know that I can save a recreation macro and then go back and use that string, but it seems this will not work programatcially.
Any other ways to "print" the string the legend command would create?
December 30, 2013 at 02:48 pm - Permalink
Use Textbox to create it instead of Legend. For example:
Textbox/C/N=text0 "\s(jack) jack"
Use AppendText to add lines to it later.
If you have an existing graph with a complex legend that you want to convert to a textbox, close the graph creating a recreation macro. In the macro replace Legend with Textbox. Execute the macro to recreate the graph.
To convert a legend to a textbox programmatically you would need to read the legend text using AnnotationInfo, create the textbox, and kill the legend.
Yes, using AnnotationInfo.
The "Annotation Proc" WaveMetrics procedure file defines a AnnotationText function that you might want to steal.
December 30, 2013 at 06:53 pm - Permalink
AnnotationInfo is what I was looking for.
Thanks again.
December 31, 2013 at 09:08 am - Permalink