Skip to content

Instantly share code, notes, and snippets.

@interrogator
Created September 27, 2015 12:15
Show Gist options
  • Save interrogator/689649f9b4aa06fdc34a to your computer and use it in GitHub Desktop.
Save interrogator/689649f9b4aa06fdc34a to your computer and use it in GitHub Desktop.
% gobble allows you to indent in your tex file
% rerun code only if it changes
\usepackage[gobble=auto,rerun=modified]{pythontex}
% a figure showing code and the image it produces
\begin{figure}[htb!]
% make a text box
\begin{mdframed}[backgroundcolor=gray!4] \footnotesize \singlespacing
% code to run and typeset it
\begin{pyblock}[Verbs]
q = r'/^VB.?/'
verbs = interrogator(corpus, 'words', q, lemmatise = True)
# plot top 7 entries as percentage of all entries:
rel_verbs = editor(verbs.results, '%', verbs.totals)
plotter('Verbs', rel_verbs.results, save = 'Verbs')
\end{pyblock}
% run, but don't typeset
\begin{pycode}
print(r"\begin{center}")
print(r"\includegraphics[width=0.85\textwidth]{../images/Verbs.png}")
print(r"\end{center}")
\end{pycode}
\end{mdframed}
\caption{Cap}
\label{fig:Verbs}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment