A few new member functions for various classes


I’d like to propose a few new member functions for various classes that would make our lives easier. I expect these will be rather easy to implement:

  1. TH1::SetLineAndMarkerColor(Color_t color) which would set the color of both the line and the marker of a histogram. It is rather annoying to have to type

all the time.

  1. TGraphErrors::AddPointAndError(Double_t x, Double_t y, Double_t ex, Double_t ey) similarly to TGraph::AddPoint(Double_t x, Double_t y)

I’d appreciate if these ideas could be considered in the near future!

Thanks for your suggestions !

For point one the two methods you mention are inherited from TAttMarker and TAttLine. It is true that the color is the only attribute common to the TAttXXX classes. The is four of them: TAttMarker TAttLine TAttFill and TAttText. TH1 inherits from all of them. Does that mean we will have to make all the 2 by 2 possible combinations ? and also the all the possible 3 by 3 combinations ? and one to set all of them in one go ? Would it not be easier to put in your code a method doing the setting you are asking for ?

For point two it is true that there is no AddPointError like we have SetPointError

Thanks Olivier for a quick reply!

Probably, but I feel like TAttFill and TAttText are used significantly less often than TAttMarker and TAttLine: almost each histogram with markers uses the lines for uncertainties, which have to have matching colors almost always. So maybe having only one combination (TAttMarker + TAttLine) is enough.

Yes you are probably right, but is not very generic. What about having a method:

TH1::SetColor(Color_t linecolor, Color_t markercolor, Color_t Ffllcolor, Color_t textcolor)

With by default: linecolor = markercolor = fillcolor = textcolor = -1
if one of the color is < 0 this method does not change the corresponding color if positive it set the color.

To do what you are looking for it will be enough to do:

h->SetColor(kRed, kRed);

Thanks, that would be great!

PR here: New Method TH1::SetColor by couet · Pull Request #15609 · root-project/root · GitHub

For the error, there is already a PR: [TGraphErrors] add AddPointError method by arabusov · Pull Request #15232 · root-project/root · GitHub