The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Label to indicate which matrix is plotted

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jdf726 Posted - 12/10/2018 : 11:33:13 AM
Origin Ver. and Service Release (Select Help-->About Origin): Origin Pro 2018
Operating System: Win 7

Part of experimental dataflow is to routinely import several matrices into projects and automatically plot them in two side-by-side plots (using originc).I have a config file that controls which matrix is plotted, but sometimes manually switch out the plotted matrix.

Is there any more-or-less built-in trick to adding the name of the plotted matrix dataset in a label near/on the plot?

In an abstract sense, this would be like when you produce a contact sheet of photographs and the file name of the photos is shown underneath each one. My matrices have names like 70FE_C2 (data column = 2) and 70FE_dx2 (x derivative of column two data), so I would be able to see from the text label the name of the dataset '70FE', which data column is plotted '2' and whether it is the raw data 'C', or its x or y derivative ('dx', 'dy').

I have briefly considered the following possibilities:

1) Add two labels to the plot template called 'matrix_left' and 'matrix_right'. At the time of import, adding the names of the plotted matrices into these. The trouble is then that these would have to be edited in the case I manually switched matrix.

2) After import, have a little labtalk script that loops over plot layers, finds what is plotted (I would have to remind myself how to do this) and then adds/updates labels.

3) Is there some kind of matrix 'legend' that I can save into the template? (Can I add text to the colour scale legend that contains the name of the plotted matrix?)

Something like '3' would be easier ;-)

J.
6   L A T E S T    R E P L I E S    (Newest First)
jdf726 Posted - 12/11/2018 : 06:36:50 AM
Yes...that is useful (and was option #3 in my original post).

It turns out that there is a 'simple' answer after all!

If you set the title text of the color bar to

%(1Y, @D)

or maybe even just

%(?Y, @D)

This inserts the name of the dataset... Doh!

I have never used the @D code before (worksheet/book names yes, matrices no...) and ?Y seems a little obscure...
(Googling such short strings is a little bit tricky!)

Now I look at the documentation (link below), this might be less surprising to someone who has used the 'axis title substitution' before (we more often type in axis titles or set them programatically with OriginC/Labtalk so I have never played with the automatic axis labelling).

Page 63: https://www.originlab.com/pdfs/Origin2017_Documentation/English/LabTalk_Scripting_Guide_E.pdf

This circuitous route to the answer typifies my interactions with Origin... ;-)
yuki_wu Posted - 12/11/2018 : 04:13:41 AM
Hi J,

Not sure if you are looking for this:
https://www.originlab.com/doc/LabTalk/ref/Text-Label-Options#Complete_List_of_.40Options

Regards,
Yuki

OriginLab
jdf726 Posted - 12/11/2018 : 03:32:22 AM
Thanks Yuki!

I very briefly looked at the code for accessing the tree structure to update the graph. THat looks like a very 'deep' branch!!!

tr.Root.Spectrums.Spectrum1.DimAxes.DimAxis2.NewAxes.NewAxis1.Title.AddNode("Text").strVal = strName;

I can try and add that into the original import script.

I have mixed success with the Labtalk command. If I put in a 5 second delay before the command and then do nothing on the PC and let the script run it works most of the time, but if I navigate away from Origin (to check my email or whatever) when I look back I seem to get an error message. This is somewhat like behaviour I have seen before where 'timing' of the rendering of graphical objects is out of sequence. I have not yet added a delay AFTER the labtalk command, perhaps that is als required (the next part of teh script exports to PNG and saves file and executes the next import).

Going back to my original question... is there any substitution notation that I can use in the color bar legend that might help? I have never even turned on the label on the colour bar, but it could be text dynamically pulled from somewhere else right?

By way if comparison, I often use the 'custom' legend dialog to include the file/sheet name of the plotted data in the legend string for line plots. In a way I just want the same functionality for matrices.


J.
yuki_wu Posted - 12/10/2018 : 10:30:12 PM
Hi,

You could customize the title of color bar via setting format tree. For example, I created a contour plot, I could rename the color bar title by:
void SetColorBarTitle()
{
    GraphPage gp = Project.ActiveLayer().GetPage();
    string strName = gp.GetName();
	GraphLayer gl = Project.ActiveLayer();
    if( !gl )
        return;
	Tree tr;
	tr.Root.Spectrums.Spectrum1.DimAxes.DimAxis2.NewAxes.NewAxis1.Title.AddNode("Text").strVal = strName;
	if(0 == gl.UpdateThemeIDs(tr.Root))
	{
		gl.ApplyFormat(tr, true, true);
		return;
	}
}

More examples please go through this page:
https://www.originlab.com/doc/OriginC/examples/Accessing-Graph-Format-with-Theme-Tree

Regards,
Yuki

OriginLab
jdf726 Posted - 12/10/2018 : 4:58:08 PM
LOL... I thought I had got it to work with this snippet, executed at the very end of the import...

for (ii = 1; ii<page.nlayers+1; ii++){
layer -o ii {
range -w rngData = 1;
range rngBook = rngData.GetPage()$;
Spectrum1.title$=rngBook.name$;
}
}

which works when I execute this in the command window...but using LT_execute() it gives me an error. "External Call execution error"!

I also tested out integrating this into the import where I already know the name of the matrices with the same kind of error.

layer -o 1 {Spectrum1.title$=NameofMatrix1};
layer -o 2 {Spectrum1.title$=NameofMatrix1};

Is it a timing problem executing formatting labtalk immediately after creating in originc?
Is there a syntax error that is tolerated in the command line but not in the LT_execute originC command?

Any ideas?
jdf726 Posted - 12/10/2018 : 12:54:22 PM
Update 1: I had a quick look at the options...

I found two ways of finding out what exists in a graph.
One is to call list -o, which gives me stuff like

1 6 OL, 0x0000000001B21E48
2 6 OB, 0x0000000001B23F48
3 0 YR, 0x0000000001B240A8
4 0 XT, 0x0000000001B24208
5 3 __BCO2, 0x0000000001B24368
6 3 3D, 0x0000000001B244C8
7 0 XB, 0x0000000001B24628
8 0 YL, 0x0000000001B24788
9 3 ZCOLORS, 0x0000000001B248E8
10 3 3DCOLOR, 0x0000000001B24A48
11 3 SPECTRUM1, 0x0000000001B24BA8
12 7* _226, 0x0000000001B24D08
13 7 _226, 0x0000000001B24E68
14 7 _226, 0x0000000001B24FC8
15 7 _202, 0x0000000001B25128
16 7 _226, 0x0000000001B25288
17 7 _226, 0x0000000001B253E8
18 7 _226, 0x0000000001B25548
19 7 _226, 0x0000000001B256A8
20 7 _226, 0x0000000001B25808
21 7 _226, 0x0000000001B25968
22 7 _226, 0x0000000001B25AC8
23 7 _226, 0x0000000001B25C28

None of that is simply the name of the plotted matrix.
I can also loop over all layers, graph objects using

doc -e LW {doc -e G { %B= } }

which gives

OL
OB
YR
XT
__BCO2
3D
XB
YL
ZCOLORS
3DCOLOR
SPECTRUM1
_226
_226
_226
_202
_226
_226
_226
_226
_226
_226
_226
_226
ttext
OL
OB
YR
XT
__BCO2
3D
XB
YL
ZCOLORS
3DCOLOR
SPECTRUM1
_226
_226
_226
_226
_226
_226
_226
_226
_202
_226
_226
_226
_226
_226
_226


The objects I recognise are
* a label called ttext which I created to display run data
* Spectrum1 which is the name of the colour bar.
* XB and YL are the axis labels which you can print out using
doc -e LW {
doc -e G {
if("%B"=="XB") %B.text$=;
}
}
* XT might be the name of the Y label in the template (in my case this is stale)

But which is the contour plot and how do I find out which matrix it corresponds to?
What are all those _226 entries?
Where is the documentation for the other objects types?

UPDATE 2: I found another way, which is to loop over layers and use a range to capture the name of the data. The other way was a red herring maybe...


for (ii = 1; ii<page.nlayers+1; ii++)
{
ii=;
layer -o ii {
range -w rngData = 1;
range rngBook = rngData.GetPage()$;
rngBook.name$=;
}
}

This outputs the book names. Now I just need to add the labels that use these text variables (the colour bar text perhaps)


J.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000