diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index ee168d8e045ab..c3e27767af36d 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -6758,9 +6758,12 @@ void TH1::SetDefaultSumw2(Bool_t sumw2) //////////////////////////////////////////////////////////////////////////////// /// Change/set the title. /// -/// If title is in the form `stringt;stringx;stringy;stringz` +/// If title is in the form `stringt;stringx;stringy;stringz;stringc` /// the histogram title is set to `stringt`, the x axis title to `stringx`, -/// the y axis title to `stringy`, and the z axis title to `stringz`. +/// the y axis title to `stringy`, the z axis title to `stringz`, and the c +/// axis title for the palette is ignored at this stage. +/// Note that you can use e.g. `stringt;stringx` if you only want to specify +/// title and x axis title. /// /// To insert the character `;` in one of the titles, one should use `#;` /// or `#semicolon`. @@ -6792,8 +6795,15 @@ void TH1::SetTitle(const char *title) fYaxis.SetTitle(str2.Data()); lns = str1.Length(); str1 = str1(isc+1, lns); - str1.ReplaceAll("#semicolon",10,";",1); - fZaxis.SetTitle(str1.Data()); + isc = str1.Index(";"); + if (isc >=0 ) { + str2 = str1(0,isc); + str2.ReplaceAll("#semicolon",10,";",1); + fZaxis.SetTitle(str2.Data()); + } else { + str1.ReplaceAll("#semicolon",10,";",1); + fZaxis.SetTitle(str1.Data()); + } } else { str1.ReplaceAll("#semicolon",10,";",1); fYaxis.SetTitle(str1.Data()); diff --git a/hist/histpainter/src/TGraphPainter.cxx b/hist/histpainter/src/TGraphPainter.cxx index e89b9da44c450..161b00696f6a0 100644 --- a/hist/histpainter/src/TGraphPainter.cxx +++ b/hist/histpainter/src/TGraphPainter.cxx @@ -4727,6 +4727,12 @@ void TGraphPainter::PaintScatter2D(TScatter2D *theScatter, Option_t* chopt) functions->AddFirst(palette); } + TString scTitle(theScatter->GetTitle()); + if (palette && scTitle.CountChar(';') == 4) { + auto pos = scTitle.Last(';') + 1; + auto cTitle = scTitle(pos, scTitle.Length() - pos); + palette->SetTitle(cTitle.Data()); + } if (palette && !optionP) palette->Paint(); } } else { diff --git a/tutorials/visualisation/graphs/gr019_scatter2d.C b/tutorials/visualisation/graphs/gr019_scatter2d.C index 7992a0bd1cd43..b9f8f92e9597d 100644 --- a/tutorials/visualisation/graphs/gr019_scatter2d.C +++ b/tutorials/visualisation/graphs/gr019_scatter2d.C @@ -43,7 +43,7 @@ void gr019_scatter2d() c1[0] = 1; auto scatter1 = new TScatter2D(n, x1, y1, z1, c1, s1); - scatter1->SetTitle("Scatter plot title;X title;Y title;Z title"); + scatter1->SetTitle("Scatter plot title;X title;Y title;Z title;C title"); scatter1->SetMarkerStyle(20); auto scatter2 = new TScatter2D(n, x2, y2, z2, c2, s2); diff --git a/tutorials/visualisation/graphs/index.md b/tutorials/visualisation/graphs/index.md index 275eeef3b1dd9..e6cb035821688 100644 --- a/tutorials/visualisation/graphs/index.md +++ b/tutorials/visualisation/graphs/index.md @@ -18,6 +18,8 @@ In addition, ROOT offers multiple variations to basic TGraphs, such as: - [TGraphSmooth](https://root.cern/doc/master/classTGraphSmooth.html) - [TGraphStruct](https://root.cern/doc/master/classTGraphStruct.html) - [TGraphTime](https://root.cern/doc/master/classTGraphTime.html). +- [TScatter](https://root.cern/doc/master/classTScatter.html). +- [TScatter2D](https://root.cern/doc/master/classTScatter2D.html). TGraphs are painted through the [TGraphPainter](https://root.cern/doc/master/classTGraphPainter.html) or [TGraph2DPainter](https://root.cern/doc/master/classTGraph2DPainter.html) classes. As a general remark, TGraphs are not binned, each point is painted individually. @@ -44,6 +46,7 @@ These examples showcase the creation of different types of graphs and basic ways | gr004_errors_asym.C | gr004_errors_asym.py | Create and draw a graph with asymmetric x & y errors. | | gr005_apply.C | gr005_apply.py | Demonstrate the functionality of the TGraph::Apply() method. | | gr006_scatter.C | gr006_scatter.py | Scatter plot for 4 variables, mapped to: x, y, marker color and marker size. | +| gr019_scatter2.C | | Scatter plot for 5 variables, mapped to: x, y, z, marker color and marker size. | | gr007_multigraph.C | gr007_multigraph.py | Create and draw a TMultiGraph (several graphs superposed). | | gr008_multierrors.C | | Graph with multiple y errors in each bin. | | gr009_bent_err.C | gr009_bent_err.py | Graph with bent (non-vertical/non-horizontal) error bars. |