Created
October 12, 2018 05:18
-
-
Save jonocarroll/2b45ac5695bb2777239566a8df759cbf to your computer and use it in GitHub Desktop.
tikz image As x-axis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## flags borrowed from | |
## http://flagpedia.net/ | |
## use LaTeX tikzDevice to render images as x-axis labels | |
## based on baptiste: https://gist.github.com/baptiste/9505ff4f54b31d1d7149e435faf295f9 | |
library(tikzDevice) | |
library(ggplot2) | |
options(tikzLatexPackages = c(getOption("tikzLatexPackages"), "\\usepackage{graphicx}\n")) | |
d <- data.frame(x = 1:10, y = 1:10) | |
p <- qplot(x, y, data = d) + | |
theme_bw() + | |
labs(x = "") + | |
theme(axis.text.x = element_text(size = 12 * 0.8, | |
lineheight = 0.9, | |
vjust = -5)) + | |
scale_x_continuous(breaks = c(2, 5, 8), | |
labels = c("\\includegraphics[scale=0.1]{us.png}", | |
"\\includegraphics[scale=0.1]{fr.png}", | |
"\\includegraphics[scale=0.1]{au.png}")) | |
tikz("xaxis.tex", standAlone = TRUE, width = 4, height = 4) | |
print(p) | |
dev.off() | |
tools::texi2dvi("xaxis.tex", pdf = TRUE) |
Author
jonocarroll
commented
Oct 12, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment