Error bars color on the legend

Dear all,

A quick question: how to add errorbars color to the legend? I need to explain what is a shaded area around the trace (+/- one standard deviation), but I cannot find the option to add this explanation to the plot legend so that is automatically updated (the name is taken from the wave name).

 

Thank you for your help.

 

Jakub

The graph with one trace and shaded error bars

Hi Jakub,

I've tried to do this in the past but I couldn't find a way. The legend dialog allows the specification of a point number of the wave being displayed but it doesn't seem to know about the error wave. Would be useful to do this but I guess no answers to your question so far means there's no way/trick.

You're right- there is no way to get Igor to include error shading in the legend symbol. There should be; maybe Igor 10? But no promises!

Well, here's something that gives the at least approximate appearance you want, with a great deal of effort and no convenience. You have to set colors yourself, and it doesn't update when you change the trace appearance.

Textbox/C/N=text0/J "\\[0\\K(49151,60031,65535)\\Z30\\x-40\\W1016\\K(65535,0,0)\\x-36\\y+13\\L0600\\K(0,0,0)\\]0\\y-13 junk"

Let's break that down...

Remember that this command requires "\\" to get a single backslash into the string that's stored in the textbox.

\[0 store the current X position in variable 0

\K(49151,60031,65535) Set the text color to light blue

\Z30 Set font size to 30 so a marker to be drawn later will be biggish

\x-40 Move the X position leftward so the marker will be at the start of the line instead of leaving a lot of blank space.

\W1016 Draw a filled box marker

\K(65535,0,0) Set the text color to red

\x-36 Move the X position leftward so that a line we are about to draw will end at the right place

\y+13 Move the Y position upward so that the line will be centered vertically over the marker

\L0600 Draw a line from the X position stored in variable 0 to the current X position

\K(0,0,0) Set text color to black

\]0 Restore font size and a couple other things from variable 0

\y-13 Undo the change in the Y position made earlier so the text will be vertically aligned correctly

junk The name of the wave I used for the graph. This will be actual text in the annotation.

I did warn you about a great deal of effort and no convenience!

GraphWithKludgyLegend.png (52.17 KB)

I have a comparable approach to show deviations in graphs that I am making. I use a arrow line as shown below (the label should say ± 1 sigma)

modification.png (117.32 KB)

You could make the update live using Johns textbox approach, but with a hook function attached to the graph which injects the latest error bar color into the textbox if some change happens. Here is a horribly hacked together function which extracts the current error bar color from WinRecreation (which you can then prepend with "\K" and insert into the textbox):

Function/S ExtractErrorBarColor()
    String Errorbar = GrepList(WinRecreation("",0), "^\tErrorBars", 0, "\r")
    Variable pos = strsearch(Errorbar,"SHADE= {",0)
    if (pos == -1)
        return ""
    endif
    Errorbar = Errorbar[pos+strlen("SHADE= {"),inf]
    pos = strsearch(Errorbar,"(",0)
    Errorbar = Errorbar[pos,inf]
    pos = strsearch(Errorbar,")",0)
    Errorbar = Errorbar[0,pos]
    return Errorbar
End

 

The default color of error bar shading is the trace color but partially transparent. If you have multiple traces and each is a different color, it should be pretty obvious which shading belongs to which trace.

If your graph is just what you've shown us, can't you just put something in the legend like "shaded area shows +/- one standard deviation"?

John's solution/hack might be very helpful if you have multiple traces and the error bar shading color has no obvious relationship to the trace color, but it doesn't seem like it would help if the information you are trying to convey is what the shading means, not which trace the shading belongs to.

It would be useful if we had an escape code that could show the trace and error bar/shading colors. Maybe \se (symbol + error) instead of just \s.