如何做天文符号“\sun”在PyX中 [英] How to do the astronomical symbol "\sun" in PyX

查看:198
本文介绍了如何做天文符号“\sun”在PyX中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图用PyX把太阳的天文象征放在一个图上,但没有成功。我的代码如下:

I've been trying to put the astronomical symbol of the sun on a graph using PyX, but so for with no success. The code I have is the following:

 from pyx import *
 from pylab import *
 x=arange(1,5,0.1)
 y=exp(-(x-3.0)**2/(2.0*0.5**2))/sqrt(2.0*pi*0.5**2)
 ######################
 g=graph.graphxy(width=8,y=graph.axis.linear(title=r"Fraction of DM halos"),x=graph.axis.linear(min=1,title=r"Mass ($10^{11}M_{\sun}$)"))
 g.plot(graph.data.values(x=x,y=y),styles=[graph.style.histogram()])
 g.writeEPSfile("testhistogram")

我尝试添加 text.set(mode =latex),然后加上 text.preamble (\usepackage {mathabx}),但这不起作用(因为我知道这个符号在mathabx LaTeX包中)。任何想法?

I tried adding text.set(mode="latex") followed by text.preamble("\usepackage{mathabx}"), but this doesn't work (because I know this symbol is on the mathabx LaTeX package). Any ideas?

推荐答案

我在这里没有使用pyx,但是您只是尝试使用Unicode字符串并传入
你想要的符号的Unicode字符?

I am without pyx here, but have you simply tried to use Unicode strings and pass in the unicode character for the symbol you want?

太阳符号的字符包含Unicode编号9737(十进制,0x2609十六进制),因此您可以尝试执行此操作:

The char for the sun symbol has unicode number 9737 (decimal, 0x2609 hex) , so you could just try doing this:

g=graph.graphxy(width=8,y=graph.axis.linear(title=r"Fraction of DM halos"),
   x=graph.axis.linear(min=1,
       title=u"Mass ($10^{11}M_\u2609$)"))

这篇关于如何做天文符号“\sun”在PyX中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆