Skip to content

Commit

Permalink
Make sure SetRangeUser works on the palette
Browse files Browse the repository at this point in the history
  • Loading branch information
couet authored and silverweed committed Aug 14, 2024
1 parent 7c85dd7 commit ca6db73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions hist/hist/src/TScatter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ TH2F *TScatter::GetHistogram() const
double dx = (rwxmax-rwxmin)*fMargin;
double dy = (rwymax-rwymin)*fMargin;
auto h = new TH2F(TString::Format("%s_h",GetName()),GetTitle(),npt,rwxmin-dx,rwxmax+dx,npt,rwymin-dy,rwymax+dy);
// h->SetMinimum(rwymin-dy);
// h->SetMaximum(rwymax+dy);
h->SetBit(TH1::kNoStats);
h->SetDirectory(nullptr);
h->Sumw2(kFALSE);
Expand Down
6 changes: 6 additions & 0 deletions hist/histpainter/src/TGraphPainter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4441,6 +4441,10 @@ void TGraphPainter::PaintScatter(TScatter *theScatter, Option_t* chopt)

TH2F *h = theScatter->GetHistogram();
if (optionAxis) h->Paint(" ");
if (h->GetMinimum() != h->GetMaximum()) {
if (minc<h->GetMinimum()) minc = h->GetMinimum();
if (maxc>h->GetMaximum()) maxc = h->GetMaximum();
}

// Define and paint palette
if (theColor) {
Expand Down Expand Up @@ -4508,6 +4512,8 @@ void TGraphPainter::PaintScatter(TScatter *theScatter, Option_t* chopt)
} else {
c = theColor[i];
}
if (c<minc) continue;
if (c>maxc) continue;
nc = TMath::Nint(((c-minc)/(maxc-minc))*(nbcol-1));
if (nc > nbcol-1) nc = nbcol-1;
theScatter->SetMarkerColor(gStyle->GetColorPalette(nc));
Expand Down
5 changes: 4 additions & 1 deletion tutorials/graphs/scatter.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void scatter()
canvas->SetRightMargin(0.14);
gStyle->SetPalette(kBird, 0, 0.6); // define a transparent palette

const int n = 100;
const int n = 175;
double x[n];
double y[n];
double c[n];
Expand All @@ -32,5 +32,8 @@ void scatter()
auto scatter = new TScatter(n, x, y, c, s);
scatter->SetMarkerStyle(20);
scatter->SetTitle("Scatter plot title;X title;Y title;Z title");
scatter->GetXaxis()->SetRangeUser(20.,90.);
scatter->GetYaxis()->SetRangeUser(55.,90.);
scatter->GetZaxis()->SetRangeUser(10.,200.);
scatter->Draw("A");
}

0 comments on commit ca6db73

Please sign in to comment.