Sharpie / RTikZDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
31 stars 36 forks source link

Factor out repeated graphics parameters #47

Open zackw opened 12 years ago

zackw commented 12 years ago

Constructs such as

\begin{tikzpicture}[x=1pt,y=1pt]
\definecolor[named]{drawColor}{rgb}{0.00,0.00,0.00}
\definecolor[named]{fillColor}{rgb}{1.00,1.00,1.00}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (144.54,144.54);
\definecolor[named]{fillColor}{rgb}{1.00,1.00,1.00}
\fill[color=fillColor] (  0.00,  0.00) rectangle (144.54,144.54);
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (144.54,144.54);
\definecolor[named]{drawColor}{rgb}{0.00,0.00,0.00}
\node[color=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.20] at ( 73.39,  9.03) {1};
\end{scope}
\begin{scope}
\path[clip] (  0.00,  0.00) rectangle (144.54,144.54);
\definecolor[named]{drawColor}{rgb}{0.00,0.00,0.00}
\node[rotate= 90.00,color=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.20] at ( 17.30, 76.40) {1};
\end{scope}
\end{tikzpicture}

contain a great deal of repetitive clipping and color specification. It would be better to emit

\begin{tikzpicture}[x=1pt,y=1pt]
\definecolor[named]{drawColor}{rgb}{0.00,0.00,0.00}
\definecolor[named]{fillColor}{rgb}{1.00,1.00,1.00}
\path[clip] (  0.00,  0.00) rectangle (144.54,144.54);
\fill[color=fillColor] (  0.00,  0.00) rectangle (144.54,144.54);
\node[color=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.20]  at ( 73.39,  9.03) {1};
\node[rotate= 90.00,color=drawColor,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.20] at ( 17.30, 76.40) {1};
\end{tikzpicture}

or, even better, noticing that the colors used are black and white,

\begin{tikzpicture}[x=1pt,y=1pt]
\path[clip] (  0.00,  0.00) rectangle (144.54,144.54);
\fill[color=white] (  0.00,  0.00) rectangle (144.54,144.54);
\node[anchor=base,inner sep=0pt, outer sep=0pt, scale= 1.20]
 at ( 73.39,  9.03) {1};
\node[rotate= 90.00,anchor=base,inner sep=0pt, outer sep=0pt, scale=  1.20]
 at ( 17.30, 76.40) {1};
\end{tikzpicture}
Sharpie commented 12 years ago

Currently, this isn't possible for the reasons listed in issue #45.