Author |
Topic ![Next Topic Next Topic](icon_go_right.gif) |
|
Cr4sZz
14 Posts |
Posted - 09/25/2018 : 11:04:18 AM
|
OriginPro 2018b (64-bit), b9.5.5.409 Operating System: Win 7 x64
Dear Origin team,
is it possible to show not only the mean value in a scatter plot with error bars, but also to show the value of the error bar in a form like "X ± y"? By "possible" I mean an automatic way of labelling. Here is a picture for clarification:
![](https://my.originlab.com/ftp/forum_and_kbase/Images/2018-09-25_165825.png)
Sincerely Cr4sZz |
|
Hideo Fujii
USA
1582 Posts |
Posted - 09/25/2018 : 11:18:35 AM
|
Hi Cr4sZz,
You can set the custom format string (in Plot Details dialog, Label tab, Label Form=Custom) like: $(wcol(n)[i], *2)±$(wcol(n+1)[i], *2) supposing that the error data column is next to the Y column (indicated by "n+1").
Note that if the label goes out of the layer frame, you can turn off the "Clip Data to Frame" option (Plot Details at layer level, Display tab).
Works?
--Hideo Fujii OriginLab |
Edited by - Hideo Fujii on 09/25/2018 11:22:11 AM |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
Cr4sZz
14 Posts |
Posted - 09/26/2018 : 04:35:46 AM
|
Hi Hideo Fuji,
yes, it works! Thank you very much. It looks like this:
![](https://my.originlab.com/ftp/forum_and_kbase/Images/2018-09-26_100557.png)
Now, I have two follow-up questions:
1) How do I format the string in order to make use of the shorter uncertainty notation with brackets? [I'd post a Wikipedia link here but the forum software thinks it's spam...] In my case, I show the mean value with 3 significant digits, as seen in the picture. I thought of multiplying the errors with a certain factor and formatting the output but this won't work due to the differences in the order of magnitude of the errors (as seen in the picture).
2) I'd prefer not to manually edit all labels where I don't have more than one value available (see rightmost point in picture). Can we insert an if-statement or something similar in order to not show the error for cases where the error does not exist or is equal to 0?
Sincerely Cr4sZz
Edit: I guess I answered a part of my 1st question using the expression:
$(wcol(n)[i], *3*)±$(wcol(n+1)[i], .2*) I exchanged the * with a . in order to set decimals places but not significant digits. It looks like this:
![](https://my.originlab.com/ftp/forum_and_kbase/Images/2018-09-26_111807.png)
Edit2: I answered my 1st question using multiplication with the factor 100 after I rounded the errors to the 0th decimal place.
$(wcol(n)[i], *3*)($(wcol(n+1)[i]*100, .0*)) It looks like this:
![](https://my.originlab.com/ftp/forum_and_kbase/Images/2018-09-26_112629.png)
Edit3: Concerning 2nd question, I tried including an if-statement but it won't work. Using
$(wcol(n)[i], *3*) $(wcol(n)[i]>0?($(wcol(n+1)[i]*100, .0*))) will result in a Math error claiming that math cannot be performed on a text column, though I even set the column types from "Text & Numeric" to "Numeric". Any ideas? Is my code correct? |
Edited by - Cr4sZz on 09/27/2018 12:01:00 PM |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
Hideo Fujii
USA
1582 Posts |
Posted - 09/26/2018 : 10:37:20 AM
|
Hi Cr4sZz,
Regarding your Question 2, as the format doesn't have IF construction, you have to construct the string for the error in the source worksheet by yourself. In the sample below, column D is a Text column, and is constructed by the conditional operator(?:) to discriminate the error less than 0.1, and the string operation for the rest. That is, col(C)<0.1?" ":"±"+left(col(C)$,4) Now, you can simply refer to this column D for the error part of the label by:$(wcol(n)[i], .2)%(wcol(n+2)[i]$)
![](https://my.originlab.com/ftp/forum_and_kbase/Images/scr_LabelWithCondition.PNG)
Hope this helps.
--Hideo Fujii OriginLab |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
Cr4sZz
14 Posts |
Posted - 09/27/2018 : 08:33:32 AM
|
Thank you for your kind help, Hideo Fuji! Sincerely Cr4sZz |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
Cr4sZz
14 Posts |
Posted - 09/27/2018 : 12:23:44 PM
|
Sorry for double posting but I have another question.
In your example, if I wanted to perform math on column C (rounding and multiplicating), I had to create another column D in which I'd perform the math and finally convert this column to strings in another column E, right? There is no function to directly convert strings to numbers in order to use only one but two extra columns, is there?
Greetings Cr4sZz |
Edited by - Cr4sZz on 09/27/2018 12:24:35 PM |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
Hideo Fujii
USA
1582 Posts |
Posted - 09/27/2018 : 2:14:11 PM
|
Hi Cr4sZz,
In the F(x)= header row, you can first calculate the value, then apply Text(<numeric value>,"fmt")$ function to convert the value to the label string. https://www.originlab.com/doc/LabTalk/ref/text-format-func For example, you can put the the following F(x) expression instead of my previous sample to multiply by 2:col(C)<0.1?" ":"±"+Text(2*col(C), ".2")$ So, you don't need to make extra 2 columns, but only one to generate the label strings.
--Hideo Fujii OriginLab
|
Edited by - Hideo Fujii on 09/27/2018 2:19:44 PM |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
Cr4sZz
14 Posts |
Posted - 09/28/2018 : 08:36:30 AM
|
Awesome, thanks a lot! |
![Go to Top of Page Go to Top of Page](icon_go_up.gif) |
|
|
Topic ![Next Topic Next Topic](icon_go_right.gif) |
|
|
|