root(cern):如何在Unicode中用标题绘制一个数字
我正在尝试通过Root-Framework(CERN)绘制一个散点图。我想用中文设置该人物的标题,但我失败了。我的设置标题的代码是
TGraphErrors graph(x,y,x_err,y_err);
char title[]=u8"圖表標題;x座標;y座標";//chinese title
graph.SetTitle(title);
,但是在图中,所有标题均在乱码文本中显示,如下图所示:
另外,如果我使用unicode string(即title [] = l“图表标题;x座标;y座标” ),因为graph.setTitle()
不支持这一点,因此我会遇到错误。但是上面的所有字符串都可以在终端中的标准输入/输出中正确显示。因此,问题似乎不是字符串包含错误编码错误的字符,但是Root-Framework无法正确执行它们。有什么方法可以在图中显示Unicode?
PS I通过root Code.cpp
运行代码,并使用G ++进行编译,但结果是相同的。我的根部版本是6.26/02,我的操作系统版本是Ubuntu 22.04。
同样,如果有一个解决方案,可以解决构建代码的方法(由G ++编译或用作根Marco),那将是很棒的。
I'm trying to draw a scatter figure via root-framework(cern). I want to set the titles of the figure in chinese, but I failed. My code for setting the title is
TGraphErrors graph(x,y,x_err,y_err);
char title[]=u8"圖表標題;x座標;y座標";//chinese title
graph.SetTitle(title);
But in the figure, all the titles are shown in garbled text as shown in the following picture shown:
Also, if I use a unicode string(i.e. wchar_t title[]=L"圖表標題;x座標;y座標"
), I will get an error since graph.SetTitle()
doesn't support that. But all strings above can show properly in the standard input/output in the terminal. So it seems that the question is not the string contains chars with wrong encoding, but root-framework can't perform them properly. Is there any way to show unicode in the figure?
p.s. I run the code by root code.cpp
and compile it with g++, but the results are the same. My root's version is 6.26/02 and my OS version is Ubuntu 22.04.
p.s. Also, if there is a solution for both way of building the code (compiled by g++ or use as a root marco),it will be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个肮脏的黑客:与其通过
tgraph :: settitle()
提供中文字符,您可以将tmathText
实例放置在您希望出现的任何地方:There is a dirty hack: instead of providing Chinese characters via
TGraph::SetTitle()
, you can placeTMathText
instances wherever you want your characters to appear: