Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions graf2d/graf/inc/TGaxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class TGaxis : public TLine, public TAttText {
TF1 *fFunction; ///<! Pointer to function computing axis values
TAxis *fAxis; ///<! Pointer to original TAxis axis (if any)
TList *fModLabs; ///< List of modified labels.
Float_t fRefLength; ///<! Reference length for automatic scaling (not saved to file)

TGaxis(const TGaxis&);
TGaxis& operator=(const TGaxis&);
Expand Down Expand Up @@ -137,6 +138,9 @@ class TGaxis : public TLine, public TAttText {

void SetLabelColor(TColorNumber lcolor);

void SetRefLength(Float_t len) { fRefLength = len; }
Float_t GetRefLength() const { return fRefLength; }

ClassDefOverride(TGaxis,6) //Graphics axis
};

Expand Down
45 changes: 42 additions & 3 deletions graf2d/graf/src/TGaxis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ End_Macro
////////////////////////////////////////////////////////////////////////////////
/// TGaxis default constructor.

TGaxis::TGaxis(): TLine(), TAttText(11,0,1,62,0.040)
TGaxis::TGaxis(): TLine(), TAttText(11,0,1,62,0.040), fRefLength(0)
{

fGridLength = 0.;
Expand Down Expand Up @@ -721,7 +721,7 @@ TGaxis::TGaxis(): TLine(), TAttText(11,0,1,62,0.040)
TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
Double_t wmin, Double_t wmax, Int_t ndiv, Option_t *chopt,
Double_t gridlength)
: TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
: TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040), fRefLength(0)
{

fWmin = wmin;
Expand Down Expand Up @@ -758,7 +758,7 @@ TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
const char *funcname, Int_t ndiv, Option_t *chopt,
Double_t gridlength)
: TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
: TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040), fRefLength(0)
{

fFunction = (TF1*)gROOT->GetFunction(funcname);
Expand Down Expand Up @@ -795,6 +795,7 @@ TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
TGaxis::TGaxis(const TGaxis& ax) :
TLine(ax),
TAttText(ax),
fRefLength(ax.fRefLength),
fWmin(ax.fWmin),
fWmax(ax.fWmax),
fGridLength(ax.fGridLength),
Expand Down Expand Up @@ -830,6 +831,7 @@ TGaxis& TGaxis::operator=(const TGaxis& ax)
if(this!=&ax) {
TLine::operator=(ax);
TAttText::operator=(ax);
fRefLength = ax.fRefLength;
fWmin=ax.fWmin;
fWmax=ax.fWmax;
fGridLength=ax.fGridLength;
Expand Down Expand Up @@ -977,6 +979,7 @@ void TGaxis::ImportAxisAttributes(TAxis *axis)
SetBit(TAxis::kMoreLogLabels, axis->TestBit(TAxis::kMoreLogLabels));
if (axis->GetDecimals()) SetBit(TAxis::kDecimals); //the bit is in TAxis::fAxis2
SetTimeFormat(axis->GetTimeFormat());
SetRefLength(axis->GetRefLength());
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1082,6 +1085,42 @@ void TGaxis::PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t yma

Double_t rwmi = wmin;
Double_t rwma = wmax;

struct AttributeRestorer {
TGaxis *fAxis;
Float_t fLabelSize, fTitleSize, fTickSize, fLabelOffset, fTitleOffset;
AttributeRestorer(TGaxis *ax) : fAxis(ax),
fLabelSize(ax->GetLabelSize()), fTitleSize(ax->GetTitleSize()),
fTickSize(ax->GetTickSize()), fLabelOffset(ax->GetLabelOffset()),
fTitleOffset(ax->GetTitleOffset()) {}
~AttributeRestorer() {
fAxis->SetLabelSize(fLabelSize);
fAxis->SetTitleSize(fTitleSize);
fAxis->SetTickSize(fTickSize);
fAxis->SetLabelOffset(fLabelOffset);
fAxis->SetTitleOffset(fTitleOffset);
}
};
AttributeRestorer restorer(this);

Double_t scale = 1.0;

if (fRefLength > 0 && gPad) {
Double_t curH = gPad->GetWh() * gPad->GetAbsHNDC();
if (curH > 0) scale = fRefLength / curH;
}

if (scale != 1.0) {
// Only scale if precision is 2 (relative sizing). Precision 3 (pixels) ignores this.
if (GetLabelFont()%10 < 3) fLabelSize *= scale;
if (GetTextFont()%10 < 3) fTitleSize *= scale;

fTickSize *= scale;
fLabelOffset *= scale;
}



chtemp = &kchtemp[0];
label = &chlabel[0];

Expand Down
7 changes: 6 additions & 1 deletion hist/hist/inc/TAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "TArrayD.h"
#include <vector>

class TVirtualPad;
class THashList;
class TAxisModLab;

Expand All @@ -44,6 +45,7 @@ class TAxis : public TNamed, public TAttAxis {
TObject *fParent = nullptr; ///<! Object owning this axis
THashList *fLabels = nullptr; ///< List of labels
TList *fModLabs = nullptr; ///< List of modified labels
Float_t fRefLength = 0; ///<! Reference length for automatic scaling (not saved to file)

/// TAxis extra status bits (stored in fBits2)
enum {
Expand Down Expand Up @@ -176,7 +178,10 @@ class TAxis : public TNamed, public TAttAxis {
virtual void UnZoom(); // *MENU*
virtual void ZoomOut(Double_t factor=0, Double_t offset=0); // *MENU*

ClassDefOverride(TAxis,10) //Axis class
void SetRefPad(TVirtualPad *pad);
Float_t GetRefLength() const { return fRefLength; }

ClassDefOverride(TAxis,11) //Axis class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to increment the class version here: the only data member you added to the class was fRefLength, which is not taking part in the I/O. This is also called a "transient" data member, and these are marked by the exclamation mark in the associated doc string.

What made you increase the class version in your most recent commit?

Copy link
Contributor Author

@JasMehta08 JasMehta08 Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification regarding the transient member. I initially kept the ClassDef version unchanged for that exact reason.

However, I later bumped it because the CI failed on roottest-root-aclic-offset-offset with a size mismatch error (Expected: 1000, Got: 1024). I misinterpreted this failure as the system rejecting the class layout change, which is why I attempted the version bump to fix it.

I have now re-analyzing the test output, I realize the failure is simply detecting the 24-byte size increase (3 axes × 8 bytes padding/float) caused by adding fRefLength.

I have reverted the ClassDef change in the latest commit. Could you advise on how to handle the roottest failure? Does the reference file (offset.ref) need to be updated to reflect the new TH1 size?

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @guitargeek can you let me know if you have any idea how should i go about combating the failing test case?

Copy link
Contributor Author

@JasMehta08 JasMehta08 Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guitargeek could please let me know how should i fix the failing test case.

Also i tried to scale the status box and legend too, but i had a few issues in it due to the internal scaling logic of them, please let me know if i should continue to try to fix them too, or only the axis being scaled is enough.

The changes only work on the local graph(c++ painters) not the web graph(JSROOT) i was also looking into if that could be implemented in the web graph too, please let me know if i should try to work on that too.

Thanks!

};

////////////////////////////////////////////////////////////////////////////////
Expand Down
18 changes: 18 additions & 0 deletions hist/hist/src/TAxis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ TAxis::TAxis()
fLast = 0;
fBits2 = 0;
fTimeDisplay = false;
fRefLength = 0;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -103,6 +104,7 @@ TAxis::TAxis(const TAxis &axis) : TNamed(axis), TAttAxis(axis)
fParent = nullptr;
fLabels = nullptr;
fModLabs = nullptr;
fRefLength = 0;

axis.TAxis::Copy(*this);
}
Expand All @@ -117,6 +119,21 @@ TAxis& TAxis::operator=(const TAxis &axis)
return *this;
}

////////////////////////////////////////////////////////////////////////////////
/// Set the reference pad for automatic axis sizing.
/// The axis will store the absolute pixel height of this pad and use it
/// to scale its attributes when drawn in other pads.

void TAxis::SetRefPad(TVirtualPad *pad)
{
if (!pad) {
fRefLength = 0;
return;
}
fRefLength = pad->GetWh() * pad->GetAbsHNDC();
}



////////////////////////////////////////////////////////////////////////////////
/// Choose a reasonable time format from the coordinates in the active pad
Expand Down Expand Up @@ -223,6 +240,7 @@ void TAxis::Copy(TObject &obj) const
axis.fTimeFormat = fTimeFormat;
axis.fTimeDisplay = fTimeDisplay;
axis.fParent = fParent;
axis.fRefLength = fRefLength;
if (axis.fLabels) {
axis.fLabels->Delete();
delete axis.fLabels;
Expand Down