-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've attached a sample tex file.

If you typeset it (i'm using XeLaTeX and SageTeX), you'll see that png
files are upscaled (badly, i might add). Turns out - they lack DPI
information. If you typeset it (completely, with XeLaTex+Sage+XeLaTeX
dance) once, then open up the png file it produces and change its DPI
metadata (in Gimp - Image->Print size...) to 300ppi, save it, then
typeset it again (without running Sage to re-generate the image this
time), it would render correctly on a page.

In the attached file i'm using width=4.2cm to do the same thing
indirectly, to demonstrate how the image should look, but that's
inconvenient (you have to do the math yourself and specify correct
width and figsize (if needed) separately).

I suspect that mathplotlib is to blame, and wanted to dig further, but
i thought i'd ask here first.

P.S. Note that i have to specify [png] when invoking sageplot,
otherwise SageTeX will fall back to png, but then claim that png is
unsupported (bullshit) and advice to use pdflatex. The use of
[imagemagick] in sagetex invocation doesn't change anything.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJRdl86AAoJEOs4Jb6SI2CwknMH/ikknqJ1LJ1/BQQUp5m+UM3j
mEvl3rsYAd9x+YZVwZHLqpQ9ws1AHa3f5AwDNHNeUdyXQhz8+ZDn4N5yaB7Blbcy
B3+d+8ACiAf8gvxLOcN/sw+GZ4Lw2yBDWKhmAMXFGY6AZxVVpE3TZ0AaZ58sPdnN
TfmXh2z2k1dUi7nCXbgIXyTRRco8I/0FSmK9qCIo5yACi1xTxvTMbt9IsBzZPzuV
sc+3jq8BOYHUO54KFS50RxdRlHRd3xW/dSbE0RrvvCUXUaZYlmRInRLl7G7yIaIT
7tNnZIwYPXsbQ5Op6MA0iLW4++yRAcB+4E5n9ML/ZhG51nPJsEPWxEohTTnrlFk=
=pLck
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


\documentclass[a4paper]{article}

\usepackage{fullpage}
\usepackage[cm-default]{fontspec}
\setromanfont{FreeSerif}
\setsansfont{FreeSans}
\setmonofont{FreeMono}
\usepackage{polyglossia}
\setdefaultlanguage{russian}
\setotherlanguage{english}
\usepackage{sagetex}

\begin{document}
С помощью Sage\TeX{} можно использовать Sage для вычислений, и вставлять 
результаты в документ \LaTeX. Например, существует 
$\sage{number_of_partitions(1269)}$ разбиений числа $1269$. Вычислять это 
самостоятельно нет необходимости, и не нужно даже вырезать и вставлять 
откуда-то это значение.

Вот пример кода Sage:

\begin{sageblock}
f(x,y) = exp(x) * sin(2*x) + y
\end{sageblock}

Вторая производная функции $f$ - это

\[
  \frac{
    \mathrm{d}^{2}
  }{
    \mathrm{d}x^{2}
  } \sage{f(x,y)} =
  \sage{diff(f, x, 2)(x)}.
\]

Вот график функции $f$ от $-1$ до $1$:

\sageplot[
  scale=0.5
]{
  implicit_plot(f, (x, -1, 1), (y, -1, 1))
 }
 
А вот трёхмерный график:

\begin{sagesilent}
u, v = var('u,v')
fx = (3+sin(v)+cos(u))*cos(2*v)
fy = (3+sin(v)+cos(u))*sin(2*v)
fz = sin(u)+2*cos(v)
\end{sagesilent}

\begin{english}
This 3d plot looks awful:
\end{english}

{\fbox{\sageplot[][png]{parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 
2*pi),frame=False,dpi=300)}}

\begin{english}
This 3d plot looks OK (scaled to match its actual dpi - its actual resolution 
is 500x500, so at 300dpi (118 dots per cm) its size should have been 4.2cm):
\end{english}

{\fbox{\sageplot[width=4.2cm][png]{parametric_plot3d([fx, fy, fz], (u, 0, 
2*pi), (v, 0, 2*pi),frame=False,dpi=300)}}

\end{document}

Reply via email to