Automatically color traces on multi-trace graph
ajleenheer
Wed, 05/25/2016 - 09:12 am
When making a graph with multiple traces or appending traces to an existing graph, it would be nice if the traces automatically got different (well-distinguishable) colors. Why do all traces start out as red? I understand that the traces can be colored using the "Make Traces Different" package, but it seems that the "Commonly-Used Colors" button in that package should be the default Igor behavior. Currently I auto-load procedures that add macro menu items & keyboard shortcuts to do this. However, I don't think a new Igor user should have to learn about either of those options to make decent-looking graphs.
Another approach is to make a graph with a number of traces and your preferred set of colors, then Graph->Capture Graph Prefs. In the dialog, turn on the XY Plots: Wave Styles checkbox and click Capture Prefs.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 25, 2016 at 12:15 pm - Permalink
String Traces = TraceNameList("",";",1) // get all the traces from the graph
Variable Items = ItemsInList(Traces) // count the traces
Make/FREE/N=(11,3) colors = {{65280,0,0}, {65280,43520,0}, {0,65280,0}, {0,52224,0}, {0,65280,65280}, {0,43520,65280}, {0,15872,65280}, {65280,16384,55552}, {36864,14592,58880}, {0,0,0},{26112,26112,26112}}
Variable i
for (i = 0; i <DimSize(colors,1); i += 1)
ModifyGraph rgb($StringFromList(i,Traces))=(colors[0][i],colors[1][i],colors[2][i]) // set new color offset
endfor
End
May 25, 2016 at 07:03 pm - Permalink
But having some common, sensible color choices as default would be a great start. Anyone who wants their own set of colors can utilize the functions we've been discussing and add menu items/shortcuts etc, but that's relatively advanced usage. A new Igor user shouldn't create graphs that by default are less readable than Excel graphs.
My point is that having all the traces on a chart red by default is terribly indistinguishable. For example, Mathematica makes the first two traces blue and purple, which are only barely distinguishable, but at least they're different.
May 26, 2016 at 11:17 am - Permalink