There is matplotlib2tikz
, which creates a TikZ/pgfplots file that can be \input
in your document. I don't know how well it works, having never used matplotlib
, but I have used matlab2tikz
from the same author, and that works well. Also, I do not know if matplotlib2tikz
supports all the different kinds of plots that matplotlib
can create – in the Matlab case there are some limitations I believe.
Edit:
For reference, here is a brief explanation of installation and use.
Having downloaded the files from github, navigate to the folder in a command line, and run python setup.py install
to install matplotlib2tikz
.
In your Python script add from matplotlib2tikz import matplotlib2tikz
, and add matplotlib2tikz('filename.tex')
after your plot, e.g.
from numpy import arange
from matplotlib2tikz import matplotlib2tikz
import matplotlib.pyplot as plt
x = arange(0,10,0.5)
plt.plot(x,x**2)
plt.title("A lovely plot")
plt.ylabel("$y=x^2$")
matplotlib2tikz('test.tex')
You can also specify the width and height of the plot in the Python script, as mentioned in the readme of matplotlib2tikz
.
Understanding that it might be difficult to switch packages, even from a deprecated one, here's an update that addresses your requirements.
In order get the sub-figure label to be displayed as a)
instead of (a)
you have two options:
Either redefine the counter displaying mechanism \thesubfigure
. By default, it is defined as
\renewcommand*{\thesubfigure}{(\alph{subfigure})}
which adds the parentheses around the (alphabetic) counter subfigure
. Therefore, using
\renewcommand*{\thesubfigure}{\alph{subfigure})}
removes the left parenthesis. However, using only this, you need to accept that text label references to sub-figures will also include this adjustment:
\documentclass{article}
\usepackage[bf]{subfigure}% http://ctan.org/pkg/subfigure
\renewcommand{\thesubfigure}{\alph{subfigure})}% (a) -> a)
\begin{document}
\begin{figure}
\centering
\subfigure[First figure\label{subfig1}]{\rule{100pt}{50pt}} \quad
\subfigure[Second figure\label{subfig2}]{\rule{100pt}{50pt}}
\caption{Some figures}\label{mainfigure}
\end{figure}
See Figure~\ref{subfig1} and~\ref{subfig2}.
\end{document}
or, change the way the sub-caption is set. That is, not mess with the counter representation, but rather the caption setup. This required a modification to \thesubfigure
and \@thesubfigure
:
\documentclass{article}
\usepackage[bf]{subfigure}% http://ctan.org/pkg/subfigure
\makeatletter
\renewcommand{\thesubfigure}{\alph{subfigure}}% (a) -> a
\renewcommand{\@thesubfigure}{\thesubfigure)\hskip\subfiglabelskip}% a -> a)
\makeatother
\begin{document}
\begin{figure}
\centering
\subfigure[First figure\label{subfig1}]{\rule{100pt}{50pt}} \quad
\subfigure[Second figure\label{subfig2}]{\rule{100pt}{50pt}}
\caption{Some figures}\label{mainfigure}
\end{figure}
See Figure~\ref{subfig1} and~\ref{subfig2}.
\end{document}
Addressing the italic shape of the sub-caption is done using the IT
package option:
\usepackage[bf,IT]{subfigure}% http://ctan.org/pkg/subfigure
In general, lower case (old-school) options like bf
, it
, and sf
reference the sub-caption label, while upper case options like BF
, IT
, and SF
reference the sub-caption title/text. See Table 1 (p 6) of the subfigure
documentation.
Here is a complete MWE using the above suggestions:
\documentclass{article}
\usepackage[bf,IT]{subfigure}% http://ctan.org/pkg/subfigure
\makeatletter
\renewcommand{\thesubfigure}{\alph{subfigure}}% (a) -> a
\renewcommand{\@thesubfigure}{\thesubfigure)\hskip\subfiglabelskip}% a -> a)
\makeatother
\begin{document}
\begin{figure}
\centering
\subfigure[First figure\label{subfig1}]{\rule{100pt}{50pt}} \quad
\subfigure[Second figure\label{subfig2}]{\rule{100pt}{50pt}}
\caption{Some figures}\label{mainfigure}
\end{figure}
See Figure~\ref{subfig1} and~\ref{subfig2}.
\end{document}
All of the above discussions pertain to sub-figures. However, since subfigure
defines an analogous sub-table component, all references to subfigure
can be replaced with subtable
.
Best Answer
The following example (using
svmono.cls
as provided in your first link) works for me.(The lipsum package is only used to add some dummy text to the example.)