Skip to content

Commit d27b9f9

Browse files
committed
[hist] support setting palette axis title in TScatter2D
1 parent e989a7d commit d27b9f9

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

hist/hist/src/TH1.cxx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6758,9 +6758,12 @@ void TH1::SetDefaultSumw2(Bool_t sumw2)
67586758
////////////////////////////////////////////////////////////////////////////////
67596759
/// Change/set the title.
67606760
///
6761-
/// If title is in the form `stringt;stringx;stringy;stringz`
6761+
/// If title is in the form `stringt;stringx;stringy;stringz;stringc`
67626762
/// the histogram title is set to `stringt`, the x axis title to `stringx`,
6763-
/// the y axis title to `stringy`, and the z axis title to `stringz`.
6763+
/// the y axis title to `stringy`, the z axis title to `stringz`, and the c
6764+
/// axis title for the palette is ignored at this stage.
6765+
/// Note that you can use e.g. `stringt;stringx` if you only want to specify
6766+
/// title and x axis title.
67646767
///
67656768
/// To insert the character `;` in one of the titles, one should use `#;`
67666769
/// or `#semicolon`.
@@ -6792,8 +6795,15 @@ void TH1::SetTitle(const char *title)
67926795
fYaxis.SetTitle(str2.Data());
67936796
lns = str1.Length();
67946797
str1 = str1(isc+1, lns);
6795-
str1.ReplaceAll("#semicolon",10,";",1);
6796-
fZaxis.SetTitle(str1.Data());
6798+
isc = str1.Index(";");
6799+
if (isc >=0 ) {
6800+
str2 = str1(0,isc);
6801+
str2.ReplaceAll("#semicolon",10,";",1);
6802+
fZaxis.SetTitle(str2.Data());
6803+
} else {
6804+
str1.ReplaceAll("#semicolon",10,";",1);
6805+
fZaxis.SetTitle(str1.Data());
6806+
}
67976807
} else {
67986808
str1.ReplaceAll("#semicolon",10,";",1);
67996809
fYaxis.SetTitle(str1.Data());

hist/histpainter/src/TGraphPainter.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,6 +4727,12 @@ void TGraphPainter::PaintScatter2D(TScatter2D *theScatter, Option_t* chopt)
47274727

47284728
functions->AddFirst(palette);
47294729
}
4730+
TString scTitle(theScatter->GetTitle());
4731+
if (palette && scTitle.CountChar(';') == 4) {
4732+
auto pos = scTitle.Last(';') + 1;
4733+
auto cTitle = scTitle(pos, scTitle.Length() - pos);
4734+
palette->SetTitle(cTitle.Data());
4735+
}
47304736
if (palette && !optionP) palette->Paint();
47314737
}
47324738
} else {

tutorials/visualisation/graphs/gr019_scatter2d.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void gr019_scatter2d()
4343
c1[0] = 1;
4444

4545
auto scatter1 = new TScatter2D(n, x1, y1, z1, c1, s1);
46-
scatter1->SetTitle("Scatter plot title;X title;Y title;Z title");
46+
scatter1->SetTitle("Scatter plot title;X title;Y title;Z title;C title");
4747
scatter1->SetMarkerStyle(20);
4848

4949
auto scatter2 = new TScatter2D(n, x2, y2, z2, c2, s2);

0 commit comments

Comments
 (0)