How to do the astronomical symbol “\sun” in PyX

倖福魔咒の 提交于 2020-01-04 02:12:11

问题


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")

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?


回答1:


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?

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$)"))


来源:https://stackoverflow.com/questions/12486778/how-to-do-the-astronomical-symbol-sun-in-pyx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!