Re: Sage + Latex - How to change a font for axes label?

100 views
Skip to first unread message

Dima Pasechnik

unread,
Jun 13, 2013, 4:25:28 PM6/13/13
to sage-s...@googlegroups.com
On 2013-06-09, Sergey Pashinin <sergeyp...@gmail.com> wrote:
> I use Ubuntu, Sage and LaTeX. Installed sage from ppa:aims/sagemath.
>
> When I do this in latex:
>
> \begin{sagesilent}
> p2 = list_plot(zip(H, f(5)), True, color='blue', axes_labels=[u'$H,$ км',u'$\mu, c$'])
> p2.fontsize(14)
> \end{sagesilent}
>
> and run
>
> sage DIPLOM.sagetex.sage`
>
> I get this:
>
> /usr/lib/sagemath/local/lib/python2.7/site-packages/matplotlib/mathtext.py:887: MathTextWarning: Font 'default' does not have a glyph for '\u043a' [U43a]
> MathTextWarning)
>
> So I have garbage instead of russian symbols.
> How can I change a font name to use not only latin symbols?
you need to tell matplotlib to use another font. E.g.

sage: import matplotlib
sage: matplotlib.rc('font', **{'sans-serif' : 'Arial','family' : 'sans-serif'})
sage: list_plot(zip([1..5],[1..5])), True, color='blue', axes_labels=[u'$H,$ км',u'$\mu, c$'])

shows axis labels in cyrillic.
This works on OSX 10.6.8 -- you might need to use a different font on
your system.

To combine this with sagetex, you'd need to put
import matplotlib
matplotlib.rc('font', **{'sans-serif' : 'Arial','family' : 'sans-serif'})
right after
\begin{sagesilent}

HTH,
Dmitrii

>
> I could not find any information about this problem.
>
> (Personally I think it is a "bug". User should be able to use unicode out of the box!)
>

Reply all
Reply to author
Forward
0 new messages