Author |
Topic  |
|
Clairekun
Germany
175 Posts |
Posted - 08/22/2020 : 07:37:52 AM
|
Origin Ver. and Service Release (Select Help-->About Origin): 2018b Operating System: Windows 10
Hello,
First of all, please excuse me if this post does not belong to this forum, it is somehow halfway between Origin "normal" forum and Labtalk.
I needed to split a graph legend because it was too large, so that I could place both parts in different parts of my layer where they weren't overlapping data points or axes.
Since Origin does not allow two simultaneous legends, one of them is simply a text box (label) with the second half of the symbols used. I included both in a graph theme.
While legends do not show unused symbols through the different graphs, I found that labels do not follow this principle. If I use all symbols in Graph1, but only some of them in Graph2, my label will not show correctly:
label -p 78.17168 8.65106 -s \l(2) %(2)
\l(3) %(3)
\l(4) %(4)
\l(5) %(5)
\l(6) %(6) ; turns into

Unlike Legend graphic objects, there is no option in my label to try and update it, so that it will not check whether the datasets are actually there.
I also tried to create a new, empty, graph layer, so that I could, hopefully, create a new legend to store that second half of my symbols but, since there is no data related to the layer, it stays as a common label.
I checked Theme Organizer to see if there was any property in the Legend that could be set in my Label in order for it to update automatically, but could find none. I could have easily missed it, though.
Is there any workaround fot this that I could include in my script? Am I missing anything obvious? Any help would be appreciated.
Thank you. |
|
Echo_Chu
China
Posts |
Posted - 08/23/2020 : 11:24:50 PM
|
Hi,
The substitutions on a legend should also be used in a text label if substition level is set as 1 as in the legend. I believe you have known about it.
However, it looks to me that your problem is because your graph does not have 5th and 6th plot. \l(5) is the symbol of 5th plot so if there is no such plot, there is nothing to be shown in legend.
Anyway, if you want to split your legend into two part in the same graph, the procedure can be 1. Make sure all the subtitutions work in your legend 2. New a text object, cut half of the text in legend and paste to the text object 3. In the Programming tab of the Proterties dialog of the text object, set "Link to (%,$), Subtitution Level" = 1

Echo OriginLab Technical Service
|
 |
|
Clairekun
Germany
175 Posts |
Posted - 08/25/2020 : 03:26:35 AM
|
Yes, I knew about it, and the problem with the specific graph shown in the example is, in fact, that there is no 5th and 6th plot.
I might have not explained myself clearly. Both legends work, and both are linked to the same layer. The main difference between the two is, since legends seem to have specific ...instructions? properties?, somehow it checks whether all items exist, and does not show those which don't - at least, as far as I've seen.
This does not happen with normal labels, where %(5) and %(6) will show instead of a blank space (or nothing at all) if the data is not there, like it would in the case of a legend.
Maybe legends do show %(n) text when no data is present and I simply have not noticed yet, though. Is this the case? |
 |
|
Echo_Chu
China
Posts |
Posted - 08/26/2020 : 11:27:20 PM
|
Hi,
OK, I see. Yes, text object won't be updated when plot is added or removed as legend. There is code behind to make legend updated automatically.
However, if you want it works in the same way, you will need to add script in text object to do the job. Please try the code as below.
layer -c;
str$="";
loop(ii,1,count)
{
str$ += "\l($(ii)) %($(ii))%(CRLF)";
}
Text.text$ = str$;

Echo Technical Service |
 |
|
Clairekun
Germany
175 Posts |
Posted - 08/27/2020 : 04:34:53 AM
|
YES!!
Thank you! I saved the graph theme using this new modification and it works flawlessly!
Let me try to understand the script:
layer -c counts the number of dataplots str$ is just blank test Loops through all lines in the legend and writes a line that follows the pattern \l(1) %(1) for each of them until there are no more dataplots. This would, therefore, not create extra \l() %() lines.
Is this correct or am I missing something?
A couple of questions (please tell me if I should create a new Labtalk Forum post for this):
1. Why use str$ = ""; instead of string str$; ?
2. Is there any way to modify this script outside the Label Properties window? As in, applying an .ogs script. I would be interested in maintaining the same theme for different types of datasets, so I would need to override the \l(ii) %(ii) part. (Opened a Labtalk Forum post for this)
Thank you. |
Edited by - Clairekun on 08/27/2020 2:14:47 PM |
 |
|
Chris D
428 Posts |
Posted - 08/28/2020 : 09:18:16 AM
|
Technically, you should use string str$ in the case. The use of str$ = "" creates a project-level string variable that unnecessarily gets stored with the project. If str$ is just by itself, Origin doesn't know to create a new variable or if it is just some undefined variable. It is ambiguous.
See this doc about variable scope: https://www.originlab.com/doc/LabTalk/guide/Data-Types-and-vars#Scope_of_Variables
Thanks, Chris Drozdowski Originlab Technical Support
|
 |
|
|
Topic  |
|
|
|