Skip to content

Commit af4ac2f

Browse files
committed
TGraph:SetNameTitle did not change the title of the underlying histogram.
This was reported here: https://sft.its.cern.ch/jira/browse/ROOT-9222
1 parent aecbe9b commit af4ac2f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

hist/hist/inc/TGraph.h

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class TGraph : public TNamed, public TAttLine, public TAttFill, public TAttMarke
170170
virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
171171
virtual void Set(Int_t n);
172172
virtual void SetPoint(Int_t i, Double_t x, Double_t y);
173+
virtual void SetName(const char *name=""); // *MENU*
174+
virtual void SetNameTitle(const char *name="", const char *title="");
173175
virtual void SetTitle(const char *title=""); // *MENU*
174176
virtual void Sort(Bool_t (*greater)(const TGraph*, Int_t, Int_t)=&TGraph::CompareX,
175177
Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111);

hist/hist/src/TGraph.cxx

+17
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,14 @@ void TGraph::SetPoint(Int_t i, Double_t x, Double_t y)
22022202
if (gPad) gPad->Modified();
22032203
}
22042204

2205+
////////////////////////////////////////////////////////////////////////////////
2206+
/// Set graph name.
2207+
void TGraph::SetName(const char *name)
2208+
{
2209+
fName = name;
2210+
if (fHistogram) fHistogram->SetName(name);
2211+
}
2212+
22052213
////////////////////////////////////////////////////////////////////////////////
22062214
/// Set graph title.
22072215

@@ -2211,6 +2219,15 @@ void TGraph::SetTitle(const char* title)
22112219
if (fHistogram) fHistogram->SetTitle(title);
22122220
}
22132221

2222+
////////////////////////////////////////////////////////////////////////////////
2223+
/// Set graph name and title
2224+
2225+
void TGraph::SetNameTitle(const char *name, const char *title)
2226+
{
2227+
SetName(name);
2228+
SetTitle(title);
2229+
}
2230+
22142231
////////////////////////////////////////////////////////////////////////////////
22152232
/// if size*2 <= fMaxSize allocate new arrays of size points,
22162233
/// copy points [0,oend).

0 commit comments

Comments
 (0)