Dear experts,
I have created my second custom axis.
I want to create more fine labels at the top (99.1, 99.2, 99.3, 99.4, …) and avoid pollution at the bottom (50, 60, 70, …)
I have tried using SetNDivisions()
, SetMaxDigits()
, SetDecimals()
, and even ChangeLabelByValue()
for two days in a row and have not been able to achieve what I wanted.
Is there any way to achieve that? Is it possible at all?
Could somebody give me a hint or, at best, reproducible?
I appreciate any help.
Here is the reproducible:
#!/usr/bin/env python3
import ROOT
ROOT.gStyle.Reset()
canvas = ROOT.TCanvas()
canvas.SetGridx()
canvas.SetGridy()
canvas.DrawFrame(0.,0.,10.,7.)
x_pos = canvas.GetUxmax()
def convert_axis1_to_axis2(x):
'''Return axis2 value given axis1'''
return 100.*ROOT.Math.gaussian_cdf(0.5*x)
for i in range(8):
print(f"Value {i:.2f} on axis1 should correspond to value {convert_axis1_to_axis2(i):.2f} on axis2!")
y_min = convert_axis1_to_axis2(canvas.GetUymin())
y_max = convert_axis1_to_axis2(canvas.GetUymax())
f1= ROOT.TF1("f1","2*ROOT::Math::gaussian_quantile_c(1-x/100., 1)",y_min,y_max)
axis = ROOT.TGaxis(x_pos, canvas.GetUymin(), x_pos-0.001, canvas.GetUymax(),"f1")
axis.SetLabelOffset(-0.07)
axis.DrawClone()
canvas.Modified()
canvas.Update()
input("wait")
cheers,
Bohdan