# Revision history [back]

I'm not really sure I understand the question (why not use LaTeX and sagetex for plotting instead of matplotlib?) but here is an example from the matplotlib site modified to run through LaTeX using sagetex with sizes modified via the solution you pointed out (which didn't work for you):

\documentclass{article}
\usepackage{sagetex}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\begin{sagesilent}
import matplotlib as mpl
mpl.use("pgf")
pgf_with_rc_fonts = {
"font.family": "serif",
"font.serif": [],                   # use latex default serif font
"font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font
}
mpl.rcParams.update(pgf_with_rc_fonts)

import matplotlib.pyplot as plt
plt.figure(figsize=(4.5,2.5))
plt.rcParams['font.size'] = 6.
plt.plot(range(5))
plt.text(0.5, 3., "serif")
plt.rcParams['font.size'] = 3
plt.text(0.5, 2., "monospace", family="monospace")
plt.rcParams['font.size'] = 24
plt.text(2.5, 2., "sans-serif", family="sans-serif")
plt.rcParams['font.size'] = 16.
plt.text(2.5, 1., "comic sans", family="Comic Sans MS")
plt.rcParams['font.size'] = 8.
plt.xlabel(u"µ is not $\\mu$")
plt.tight_layout(.5)
plt.savefig('MyPic.pdf')
\end{sagesilent}
Sagetex let's you use matplotlib in creating pictures.
This is a modification of an example comes from:
\begin{verbatim}
http://matplotlib.org/users/pgf.html
\end{verbatim}
and it's running in \LaTeX \,with the power of the sagetex package.
\begin{center}
\includegraphics[width=5in,height=4in]{MyPic.pdf}
\end{center}
\end{document}


When I ran the code in SagemathCloud I didn't get the comic-sans font (perhaps it's not available in SMC?!?) but everything else seems in order and font sizes are modified.

But the examples shown on that page aren't particularly "LaTeX-like" as the page seems to indicate. If you use LaTeX for the typesetting and Sage for calculations, such as is done for the Cantor function in the answer by DJP then you're getting the LaTeX control over the picture and sagetex is performing the calculations needed for the plot. This addresses the while avoiding matplotlib, giving pictures in tikzpicture environment which look soooo much better.

I'm not really sure I understand the question (why not use LaTeX and sagetex for plotting instead of matplotlib?) but here is an example from the matplotlib site modified to run through LaTeX using sagetex with sizes modified via the solution you pointed out (which didn't work for you):

\documentclass{article}
\usepackage{sagetex}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\begin{sagesilent}
import matplotlib as mpl
mpl.use("pgf")
pgf_with_rc_fonts = {
"font.family": "serif",
"font.serif": [],                   # use latex default serif font
"font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font
}
mpl.rcParams.update(pgf_with_rc_fonts)

import matplotlib.pyplot as plt
plt.figure(figsize=(4.5,2.5))
plt.rcParams['font.size'] = 6.
plt.plot(range(5))
plt.text(0.5, 3., "serif")
plt.rcParams['font.size'] = 3
plt.text(0.5, 2., "monospace", family="monospace")
plt.rcParams['font.size'] = 24
plt.text(2.5, 2., "sans-serif", family="sans-serif")
plt.rcParams['font.size'] = 16.
plt.text(2.5, 1., "comic sans", family="Comic Sans MS")
plt.rcParams['font.size'] = 8.
plt.xlabel(u"µ is not $\\mu$")
plt.tight_layout(.5)
plt.savefig('MyPic.pdf')
\end{sagesilent}
Sagetex let's you use matplotlib in creating pictures.
This is a modification of an example comes from:
\begin{verbatim}
http://matplotlib.org/users/pgf.html
\end{verbatim}
and it's running in \LaTeX \,with the power of the sagetex package.
\begin{center}
\includegraphics[width=5in,height=4in]{MyPic.pdf}
\end{center}
\end{document}


When I ran the code in SagemathCloud I didn't get the comic-sans font (perhaps it's not available in SMC?!?) but everything else seems in order and font sizes are modified.modified. I don't see how Tikz is use here.

But the examples shown on that page aren't particularly "LaTeX-like" as the page seems to indicate. If you use LaTeX for the typesetting and Sage for calculations, such as is done for the Cantor function in the answer by DJP then you're getting the LaTeX control over the picture and sagetex is performing the calculations needed for the plot. This addresses the while avoiding matplotlib, giving pictures in tikzpicture environment which look soooo much better.

I'm not really sure I understand the question (why not use LaTeX and sagetex for plotting instead of matplotlib?) but here is an example from the matplotlib site modified to run through LaTeX using sagetex with sizes modified via the solution you pointed out (which didn't work for you):

\documentclass{article}
\usepackage{sagetex}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\begin{sagesilent}
import matplotlib as mpl
mpl.use("pgf")
pgf_with_rc_fonts = {
"font.family": "serif",
"font.serif": [],                   # use latex default serif font
"font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font
}
mpl.rcParams.update(pgf_with_rc_fonts)

import matplotlib.pyplot as plt
plt.figure(figsize=(4.5,2.5))
plt.rcParams['font.size'] = 6.
plt.plot(range(5))
plt.text(0.5, 3., "serif")
plt.rcParams['font.size'] = 3
plt.text(0.5, 2., "monospace", family="monospace")
plt.rcParams['font.size'] = 24
plt.text(2.5, 2., "sans-serif", family="sans-serif")
plt.rcParams['font.size'] = 16.
plt.text(2.5, 1., "comic sans", family="Comic Sans MS")
plt.rcParams['font.size'] = 8.
plt.xlabel(u"µ is not $\\mu$")
plt.tight_layout(.5)
plt.savefig('MyPic.pdf')
\end{sagesilent}
Sagetex let's you use matplotlib in creating pictures.
This is a modification of an example comes from:
\begin{verbatim}
http://matplotlib.org/users/pgf.html
\end{verbatim}
and it's running in \LaTeX \,with the power of the sagetex package.
\begin{center}
\includegraphics[width=5in,height=4in]{MyPic.pdf}
\end{center}
\end{document}


When I ran the code in SagemathCloud I didn't get the comic-sans font (perhaps it's not available in SMC?!?) but everything else seems in order and font sizes are modified. I don't see how Tikz is use here.

But the examples shown on that page aren't particularly "LaTeX-like" as the page seems to indicate. If you use LaTeX for the typesetting and Sage for calculations, such as is done for the Cantor function in the answer by DJP then you're getting the LaTeX control over the picture and sagetex is performing the calculations needed for the plot. This addresses the solves the problem of being LaTeX friendly while avoiding matplotlib, matplotlib (why is matplotlib so necessary?), giving pictures in tikzpicture environment which look soooo much better.