Dear ROOT Talk,
I am certain this is covered somewhere already - I just can’t find it.
Is there a way of changing the color of an individual data point for a TGraph?
Take a sine wave and say I want to emphasize the maximum by using a different color - how would I do this?
TGraph uses only one color for all the markers. The way to do what you are requesting is by making two graphs with different colors and plotting them on top of each others (you can use TMultiGraph for that). There is no “better way” for the time being.
Thanks for the prompt reply - that is what I thought, but I just wanted to make sure…
I can think of 2 ways doing what you want.
Split your datapoints into different parts for the different colors, create TGraphs from them with the corresponding colors and use a TMultiGraph for the drawing. This gives you the opportunity that TMultiGraph takes care of creating axes that fit the ranges of all your subgraphs.
Use the TGraph::DrawGraph(…) method to draw your graphs and change the attributes of the TGraph every time before invoking DrawGraph(…) for the subgraphs. There you have to take care for the axis ranges for yourself.
Both methods work for datapoints but not for lines between the datapoints since you splitted your data, so drawing options like “L” and “C” or for a TGraphErrors “3” and “4” are not working properly.