Author |
Topic  |
|
ONeilll
33 Posts |
Posted - 05/05/2020 : 04:47:50 AM
|
Origin Ver. and Service Release: OriginPro 2020 (64-bit) SR1 Operating System: Windows 10
Hi guys, I am using the following code to find a maximum value in a data set and plot two ranges (before and after max) in one layer:
col(A)[L]$ = "relative pressure"; // Long name col(A)[U]$ = ; // Units col(B)[L]$ = "volume@STP"; // Long name col(B)[U]$ = cc/g; // Units %A = page.info.system.import.filename$; //Get the filename %B = %[%A, '.']; // Create range for entire col 2 range rCol2 = col(2); // stats X-Function will give us maximum value and number of rows stats ix:=rcol2; // Get row index of maximum value (or first occurrence of max value) int nIdx = list(stats.max, rCol2); // Declare range for row 1 to row index of max value range r1 = rCol2[1:$(nIdx)]; // Plot that range plotxy iy:=r1 plot:=202 ogl:=[<new template:= isothermeN2 name:= %A>]; // Check to make sure max value isn't the last row before making second plot // If it is the last row, we don't need the second plot if (nIdx < stats.n) { // Declare range for next row after max to end of range range r2 = rCol2[$(nIdx):end];
// Plot that range into same layer as previous plot plotxy iy:=r2 plot:=202 ogl:=1; }
The legend produced has then the form: \l(1) %(1) \l(2) %(2)
I would like it to be \l(1)\l(2) %B, but for some reason even if I save that in the template it does not work. Thus, I would like to include that in my labtalk code. Can you guys help with this issue? Many thanks for your help!
|
|
lkb0221
China
497 Posts |
Posted - 05/05/2020 : 12:38:49 PM
|
The legend will be auto-updated when the graph been created. So I'll say the safe way is to just delete the default legend and add your own text object, with that syntax. You will need to set the level of substitution manually for that obj, in properties, and it can be thus saved in the template. |
Edited by - lkb0221 on 05/05/2020 12:39:13 PM |
 |
|
cpyang
USA
1406 Posts |
Posted - 05/05/2020 : 1:07:50 PM
|
Or you can just rename the legend in the template to like "Legend1".
%B as a string register is being used in various places, so should not be used in a graph. You can define your project string variable and use that instead, like adding
myB$ = %[%A, '.'];
and in the legend, "\(1) %(myB$)"
CP
|
 |
|
|
Topic  |
|
|
|