Skip to content

Instantly share code, notes, and snippets.

@smasongarrison
Forked from JoFrhwld/ling-plot.Rnw
Last active August 29, 2015 14:17
Show Gist options
  • Save smasongarrison/c803e4deab7f5ad30d5f to your computer and use it in GitHub Desktop.
Save smasongarrison/c803e4deab7f5ad30d5f to your computer and use it in GitHub Desktop.
\documentclass{beamer}
\usetheme{Singapore}
\usepackage{tipa}
%% Make the r-code small
\ifdefined\knitrout
\renewenvironment{knitrout}{\begin{footnotesize}}{\end{footnotesize}}
\else
\fi
\title{Putting IPA Characters in Plots}
\author{Josef Fruehwald}
\begin{document}
%% Don't print errors, warnings, or messages
\SweaveOpts{message=F, error=F, warning=F}
\begin{frame}[fragile]
\frametitle{Set up}
<<>>=
library(ggplot2)
library(tikzDevice)
@
\end{frame}
\begin{frame}[fragile]
Just put in any special \LaTeX package you want to use here.
<<tidy=F>>=
options(tikzLatexPackages = c(getOption("tikzLatexPackages"),
"\\usepackage{tipa}",
"\\usepackage{qtree}"))
@
\end{frame}
\begin{frame}[fragile]
\frametitle{Fake up some data}
<<tidy=F>>=
levels(mpg$drv) <- c("\\textipa{D}",
"\\textipa{C}",
"\\textipa{P}")
@
\end{frame}
\begin{frame}[fragile]
\frametitle{Profit}
<<dev="tikz", fig.width=8, fig.height=5, out.width="0.9\\textwidth", fig.align="center", tidy = F>>=
ggplot(mpg, aes(displ, hwy, label = drv, color = drv)) +
geom_text() +
stat_smooth()+
xlab("\\textipa{IPA!}")
@
\end{frame}
\begin{frame}[fragile]
\frametitle{Profit}
<<dev="tikz", fig.width=8, fig.height=5, out.width="0.7\\textwidth", fig.align="center", tidy = F>>=
ggplot(mpg, aes(displ, hwy, label = drv, color = drv)) +
geom_text() +
stat_smooth()+
xlab("\\textipa{IPA!}")+
annotate(x=5.5, y = 40, geom = "text",
label = "\\Tree [.S \\qroof{I}.NP \\qroof{just blew my own mind}.VP ]")
@
\end{frame}
\begin{frame}[fragile]
\frametitle{Fake up some data}
<<tidy=F>>=
mpg$tree <- "{\\footnotesize \\Tree [.S NP VP ]}"
@
\end{frame}
\begin{frame}[fragile]
\frametitle{Profit}
<<dev="tikz", fig.width=8, fig.height=5, out.width="0.7\\textwidth", fig.align="center", tidy = F>>=
ggplot(mpg, aes(displ, hwy, label = tree))+
geom_text() +
stat_smooth()+
xlab("TREES")
@
\end{frame}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment