I posted this question at tex.stackexchange.com
less than two weeks ago, nobody has been able to suggest a solution, so I hope that it is not a problem that I duplicate the question here.
I want to use tikz to inlcude R plots in my documents. I want to set absolutely all typefaces, fontsizes, fontweights to the TeX-document font body. I looked up the documentation of tikzDevice and par(), however I wasn't able to find a way to do this. Attached is a sample R-script generating some figure which needs to be cured:
library(tikzDevice)
tikz("/home/marius/Dokumenter/stk1110/oblig2/fig1.tex", width = 6, height = 5, pointsize=11)
# some data
menn = c(36.1,36.3,36.4,36.6,36.6,36.7,36.7,37.0,36.5,37.1)
kvinner = c(36.6,36.7,36.8,36.8,36.7,37.0,37.1,37.3,36.9,37.4)
par(mfrow=c(2,3))
# first row
boxplot(menn)
qqnorm(menn)
qqline(menn)
hist(menn, freq=FALSE)
x = seq(36,37.4,0.01)
lines(x, 1/(2*pi*var(menn))^0.5*exp(-(x-mean(menn))^2/(2*var(menn))))
# second row
boxplot(kvinner)
qqnorm(kvinner)
qqline(kvinner)
hist(kvinner, freq=FALSE)
lines(x, 1/(2*pi*var(kvinner))^0.5*exp(-(x-mean(kvinner))^2/(2*var(kvinner))))
par(ps=1, cex=1, cex.main=111, cex.lab=111, cex.axis=111, cex.sub=111, font.main=1)
dev.off()
And a TeX document:
\documentclass[11pt,norsk,a4paper]{article}
\usepackage[norsk]{babel}
\usepackage[paper=a4paper, top=1in,bottom=1.1in,right=0.9in,left=0.9in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[makeroom]{cancel}
\usepackage{amsmath,amsthm}
\usepackage{newtxtext}
\usepackage[T1]{fontenc}
\usepackage{pgf, pgfplots}
\usepackage{textcomp}
\date{\normalsize \today}
\begin{document}
I want all fonts in R plots to be exactly like this one.
\begin{figure}[!htbp]
\begin{center}
\input{fig1.tex}
\end{center}
\end{figure}
\end{document}
I'd like this to work for the majority of different plots in R, if not all, so that I can have exactly the same font as my document body. Even for figure titles. Are you able to suggest an solution?