Das ist das R-file...
library(tikzDevice) tikz('t-h.tex') hist(sample(-29:29,166,rep=TRUE)) hist(rnorm(1000, 250, 1.4)) dev.off()
Diese binde ich in mein eigenes tex-file ein.
%% t.tex \documentclass{scrartcl} \usepackage{xltxtra} \defaultfontfeatures{Mapping=tex-text} \usepackage{graphicx} \usepackage{polyglossia} \setdefaultlanguage[spelling=new]{german} \usepackage{tikz} \begin{document} \section{Histogramm} \input{t-h.tex} \end{document}
Ich möchte sie gerne realtiv (am besten zur Seitengröße und/oder Textbreite/-höhe) festlegen. Der tikz()-Aufruf in R hat zwar die Paramter width und heigth, meint damit aber absolute Werte in inch.
Wie geht man das an? Welche Komponenten (R, tikzDevice, tikz, tex selbst, ...?) muss ich anfassen dafür?
Beispielsweise möchte ich, das beide Grafiken zusammen auf eine Seite passen.
Eine andere (bessere) Variante wäre auch, das beide Grafiken nebeneinander stehen sollen (jede ca. 45% der Textbreite breit). Vermutlich müsste ich dann zwei separate R-files daraus machen.
Die generierte t-h.tex
% Created by tikzDevice version 0.8.1 on 2015-10-29 21:23:18 % !TEX encoding = UTF-8 Unicode \begin{tikzpicture}[x=1pt,y=1pt] \definecolor{fillColor}{RGB}{255,255,255} \path[use as bounding box,fill=fillColor,fill opacity=0.00] (0,0) rectangle (505.89,505.89); \begin{scope} \path[clip] ( 0.00, 0.00) rectangle (505.89,505.89); \definecolor{drawColor}{RGB}{0,0,0} \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.20] at (264.94,477.15) {\bfseries Histogram of sample(-29:29, 166, rep = TRUE)}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (264.94, 15.60) {sample(-29:29, 166, rep = TRUE)}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 10.80,258.94) {Frequency}; \end{scope} \begin{scope} \path[clip] ( 0.00, 0.00) rectangle (505.89,505.89); \definecolor{drawColor}{RGB}{0,0,0} \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 65.18, 61.20) -- (464.71, 61.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 65.18, 61.20) -- ( 65.18, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (131.77, 61.20) -- (131.77, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (198.36, 61.20) -- (198.36, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (264.95, 61.20) -- (264.95, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (331.53, 61.20) -- (331.53, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (398.12, 61.20) -- (398.12, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (464.71, 61.20) -- (464.71, 55.20); \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 65.18, 39.60) {-30}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (131.77, 39.60) {-20}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (198.36, 39.60) {-10}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (264.95, 39.60) {0}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (331.53, 39.60) {10}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (398.12, 39.60) {20}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (464.71, 39.60) {30}; \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20, 75.85) -- ( 49.20,408.75); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20, 75.85) -- ( 43.20, 75.85); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,159.07) -- ( 43.20,159.07); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,242.30) -- ( 43.20,242.30); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,325.53) -- ( 43.20,325.53); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,408.75) -- ( 43.20,408.75); \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80, 75.85) {0}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,159.07) {5}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,242.30) {10}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,325.53) {15}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,408.75) {20}; \end{scope} \begin{scope} \path[clip] ( 49.20, 61.20) rectangle (480.69,456.69); \definecolor{drawColor}{RGB}{0,0,0} \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 65.18, 75.85) rectangle ( 98.48,258.94); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 98.48, 75.85) rectangle (131.77,308.88); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (131.77, 75.85) rectangle (165.06,242.30); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (165.06, 75.85) rectangle (198.36,392.11); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (198.36, 75.85) rectangle (231.65,242.30); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (231.65, 75.85) rectangle (264.95,358.82); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (264.95, 75.85) rectangle (298.24,358.82); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (298.24, 75.85) rectangle (331.53,275.59); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (331.53, 75.85) rectangle (364.83,442.04); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (364.83, 75.85) rectangle (398.12,192.36); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (398.12, 75.85) rectangle (431.41,325.53); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (431.41, 75.85) rectangle (464.71,275.59); \end{scope} \end{tikzpicture} \begin{tikzpicture}[x=1pt,y=1pt] \definecolor{fillColor}{RGB}{255,255,255} \path[use as bounding box,fill=fillColor,fill opacity=0.00] (0,0) rectangle (505.89,505.89); \begin{scope} \path[clip] ( 0.00, 0.00) rectangle (505.89,505.89); \definecolor{drawColor}{RGB}{0,0,0} \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.20] at (264.95,477.15) {\bfseries Histogram of rnorm(1000, 250, 1.4)}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (264.95, 15.60) {rnorm(1000, 250, 1.4)}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 10.80,258.94) {Frequency}; \end{scope} \begin{scope} \path[clip] ( 0.00, 0.00) rectangle (505.89,505.89); \definecolor{drawColor}{RGB}{0,0,0} \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (105.13, 61.20) -- (424.76, 61.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (105.13, 61.20) -- (105.13, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (185.04, 61.20) -- (185.04, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (264.95, 61.20) -- (264.95, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (344.85, 61.20) -- (344.85, 55.20); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (424.76, 61.20) -- (424.76, 55.20); \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (105.13, 39.60) {246}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (185.04, 39.60) {248}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (264.95, 39.60) {250}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (344.85, 39.60) {252}; \node[text=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at (424.76, 39.60) {254}; \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20, 75.85) -- ( 49.20,394.83); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20, 75.85) -- ( 43.20, 75.85); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,139.64) -- ( 43.20,139.64); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,203.44) -- ( 43.20,203.44); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,267.24) -- ( 43.20,267.24); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,331.04) -- ( 43.20,331.04); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 49.20,394.83) -- ( 43.20,394.83); \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80, 75.85) {0}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,139.64) {50}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,203.44) {100}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,267.24) {150}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,331.04) {200}; \node[text=drawColor,rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.00] at ( 34.80,394.83) {250}; \end{scope} \begin{scope} \path[clip] ( 49.20, 61.20) rectangle (480.69,456.69); \definecolor{drawColor}{RGB}{0,0,0} \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] ( 65.18, 75.85) rectangle (105.13, 78.40); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (105.13, 75.85) rectangle (145.09,100.09); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (145.09, 75.85) rectangle (185.04,144.75); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (185.04, 75.85) rectangle (224.99,265.96); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (224.99, 75.85) rectangle (264.95,396.11); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (264.95, 75.85) rectangle (304.90,442.04); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (304.90, 75.85) rectangle (344.85,291.48); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (344.85, 75.85) rectangle (384.80,147.30); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (384.80, 75.85) rectangle (424.76, 89.88); \path[draw=drawColor,line width= 0.4pt,line join=round,line cap=round] (424.76, 75.85) rectangle (464.71, 78.40); \end{scope} \end{tikzpicture}