Home | News | Documentation | Download

TAxis label math expression problem


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18
Platform: WSL
Compiler: C++11


Hello.
I am adding text labels to TAxis and some of them are math expressions with bars on top (image attached). However, the barred text are shifted below quite a bit compared to the unbarred text. Is there any way to avoid this?
Thanks for helping.IMG_20200123_015347

Thanks! For me, the following works:

binName[0] = "#lower[0.23]{#Sigma}";
binName[1] = "#bar{#Sigma}";

Can it be done without the lower method, since I have to explicitly give value for each? I tried the rest of the methods in your comments. I am using the following macro to format the string:

float formatLowerVal {0.24};
char *buf {new char[10]};
sprintf(buf,"#lower[%.2f]{",formatLowerVal);
string strFormatStart {buf};
delete[] buf;
string strFormatEnd {"}"};
for (int i = 0; i < binCount; ++i)
{
	if(binName[i].find("bar") == -1)
	{
		binName[i] = strFormatStart+binName[i]+strFormatEnd;
	}
}

Try:

binName[0] = "#color[0]{#bar{|}}#Sigma";
binName[1] = "#color[0]{#bar{|}}#bar{#Sigma}";

Thanks! Just what I wanted :slight_smile: