Home > tikz pgf > Overlay two .tikz files from input

# Overlay two .tikz files from input

March 11Hits:2

I have some plots generated from matlab2tikz which I would like to overlay. Each plot is a seperate .tikz file which I input using \input. My code currently is:

\pgfplotsset{ every axis/.append style={ scale only axis,    }, /tikz/every picture/.append style={ trim axis left, trim axis right,     } }  \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} \begin{table}[h!]\centering        \begin{center}      \begin{tabular}{P{6cm} P{6cm}}      \toprule       R220expt21 & R60expt\\       \cmidrule(r){1-1}\cmidrule(l){2-2}       \scalebox{0.4}{\input{images/expt21nrmse.tikz}}\llap{\raisebox{0.5cm}{\scalebox{0.2}                  {\input{images/expt21nrmse.tikz}}}}       \scalebox{0.4}{\input{images/expt21fitD.tikz}}               &            \scalebox{0.4}{\input{images/expt2nrmse.tikz}}       \scalebox{0.4}{\input{images/expt2fitD.tikz}}       \\ \bottomrule       \end{tabular}       \caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}       \label{tbl:1}       \end{center} \end{table} 


Currently this code produces:

As you can see the inset of the top left image is looking fine, but I would like to shift it around horizontally too. I tried the solutions in the topic "Horizontal equivalent to \raisebox?" but I get an error about being in horizontal mode.

My questions are:

• Is there a method, keeping with what I do currently in using \input, to neatly position a subplot?
• Is my method bad practice, if so what should I be doing?

Edit 2: FULL MWE:

\documentclass[11pt,a4paper]{report}  \usepackage[a4paper,vmargin={30mm,30mm},hmargin={30mm,30mm}]{geometry} \usepackage{graphicx,array,booktabs,pgfplots} \usetikzlibrary{calc}  \newsavebox{\mybox} %\sbox{\mybox}{\input{images/exp5nrmse.tikz}} \sbox{\mybox}{%   Just use \input{images/exp5nrmse.tikz} instead of following  \begin{tikzpicture} \begin{axis}[% width=4.52083333333333in, height=3.565625in, scale only axis, xmin=1, xmax=511, xlabel={$q (\mu m^{-1})$}, ymin=0.5, ymax=1, ylabel={Normalized RMS error} ] \addplot [color=blue,solid,line width=1.0pt,forget plot]   table[row sep=crcr]{ 10  0.49608542  \\ 11  0.5509195   \\ 12  0.54464869  \\ 13  0.54379236  \\ 14  0.60808362  \\ 15  0.49726539  \\ 16  0.61919337  \\ 17  0.66339954  \\ 18  0.72671426  \\ 19  0.71607429  \\ }; \end{axis} \end{tikzpicture}% }  \pgfplotsset{ every axis/.append style={ scale only axis,    }, /tikz/every picture/.append style={ trim axis left, trim axis right,     } }  \begin{document}  \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} \begin{table}[htb!]  \centering      \begin{tabular}{P{5.5cm} P{5.5cm}}      \toprule       R220expt21 & R60expt\\       \cmidrule(r){1-1}\cmidrule(l){2-2}       \tikz[remember picture,baseline=(a.base)]\node[scale=0.4,outer sep=0pt]                (a){\usebox{\mybox}};        %%% Change dimensions in $(a.east)+(-0.9,0cm)$       \tikz[remember picture,overlay]\node[anchor=east,outer sep=0pt,scale=0.2] at                ($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};       \scalebox{0.4}{\usebox{\mybox}}       &       \scalebox{0.4}{\usebox{\mybox}}       \scalebox{0.4}{\usebox{\mybox}}       \\ \bottomrule       \end{tabular}       \caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}       \label{tbl:1} \end{table}  \end{document} 


Hopefully this will work with \input too.

You can use a node to put your .tikz files

\documentclass{article}
\usepackage{graphicx,array,booktabs,tikz}
\usetikzlibrary{calc}
\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
\centering
\begin{tabular}{P{5.5cm} P{5.5cm}}
\toprule
R220expt21 & R60expt\\
\cmidrule(r){1-1}\cmidrule(l){2-2}
\tikz[remember picture,baseline=(a.base)]\node[scale=0.4,outer sep=0pt]
(a){\includegraphics[width=6cm]{example-image-a}};
%%% Change dimensions in $(a.east)+(-0.5,0cm)$
\tikz[remember picture,overlay]\node[anchor=east,outer sep=0pt,scale=0.2] at
($(a.east)+(-0.5,0cm)$){\includegraphics[width=6cm]{example-image-b}};
\scalebox{0.4}{\includegraphics[width=6cm]{example-image-c}}
&
\scalebox{0.4}{\includegraphics[width=6cm]{example-image-a}}
\scalebox{0.4}{\includegraphics[width=6cm]{example-image}}
\\ \bottomrule
\end{tabular}
\caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}
\label{tbl:1}
\end{table}

\end{document}



# update:

\documentclass{article}
\usepackage{graphicx,array,booktabs,pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{calc}

%% use as many boxes as you need for each plot.
\newsavebox{\mybox}
%\sbox{\mybox}{\input{images/exp5nrmse.tikz}}
\sbox{\mybox}{%   Just use \input{images/exp5nrmse.tikz} instead of following
\begin{tikzpicture}
\begin{axis}[%
width=4.52083333333333in,
height=3.565625in,
scale only axis,
xmin=1,
xmax=511,
trim axis left,
trim axis right,
xlabel={$q (\mu m^{-1})$},
ymin=0.5,
ymax=1,
ylabel={Normalized RMS error}
]
table[row sep=crcr]{
10  0.49608542  \\
11  0.5509195   \\
12  0.54464869  \\
13  0.54379236  \\
14  0.60808362  \\
15  0.49726539  \\
16  0.61919337  \\
17  0.66339954  \\
18  0.72671426  \\
19  0.71607429  \\
};
\end{axis}
\end{tikzpicture}%
}%
\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
\centering
\begin{tabular}{P{5.5cm} P{5.5cm}}
\toprule
R220expt21 & R60expt\\
\cmidrule(r){1-1}\cmidrule(l){2-2}
\begin{tikzpicture}[baseline=(a.base)]
\node[scale=0.4,outer sep=0pt]  (a){\usebox{\mybox}};
%%% Change dimensions in $(a.east)+(-0.9,0cm)$
\node[anchor=east,outer sep=0pt,scale=0.2] at
($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};
\end{tikzpicture}
\scalebox{0.4}{\usebox{\mybox}}
&
\scalebox{0.4}{\usebox{\mybox}}
\scalebox{0.4}{\usebox{\mybox}}
\\ \bottomrule
\end{tabular}
\caption{Fitted results for two samples. (top) NRMSE values for each q. (bottom) Fitted diffusion. (bottom insert) 2 Highlighted DICF and theoretical fits.}
\label{tbl:1}
\end{table}

\end{document}



## Related Articles

• ### Overlay two .tikz files from inputMarch 11

I have some plots generated from matlab2tikz which I would like to overlay. Each plot is a seperate .tikz file which I input using \input. My code currently is: \pgfplotsset{ every axis/.append style={ scale only axis, }, /tikz/every picture/.append

• ### Specific .tikz file cannot be input in LaTeXOctober 10

I have created this surface plot in Matlab and use the wonderful program Matlab2tikz to export it to LaTeX. It generates me a .tikz file and when I try to use it I get an error. I have found out! that there are some lines in the code: title={\$\text{v

• ### TikZ: Random characters with tikz, fontenc and inputMay 30

I am getting random characters displayed in my TikZ images: I have just noticed this recently. I am not sure what this might be caused by. I am using the latest TikZ build from TeXample. I only observe this behaviour, when I create the image by using

• ### How to include arrows in a .tikz file, which is generated with matlab2tikz?August 29

I made a plot with matlab. Then I generated a .tikz file with matlab2tikz. Now i want to insert arrows in the .tikz file and also write something left of the arrow. I can make arrows and text in the plot, but matlab2tikz don't know the textbox. So th

• ### How to create and include .tikz files in your manuscript?November 23

Recently, I learnt about the matlab code matlab2tikz. The output of this code is a .tikz file that can be used, I guess, alongside standard figure packages with a simple line \input{mysphere.tikz} in the figure environment. This got me wondering if .

• ### Scale markers in external Tikz fileApril 2

I use external .tikz files to include graphics in my LaTeX document. These .tikz files are generated by matlab2tikz. The scatter plots that come out though have very small markers. I want to scale these markers. Right now I include the .tikz file as

• ### Change axis number format for external tikz fileApril 3

I'm using \input{filename.tikz} to include .tikz graphs created by matlab2tikz in my LaTeX document. As shown in a comment on this question it is possible to change the plot marker size when the document is inputted, without altering the original .ti

• ### Modify tikzpicture plot outside .tikz fileMarch 9

I am not sure if my title gets through what I'm after, but basically I am using matlab2tikz to generate some plots for me and am wondering how you can do some modifications from outside the .tikz file. e.g a .tikz from matlab2tikz will be like: \begi

• ### How to put TikZ file from Matlab to Latex? June 20

I made TikZ file in Matlab using function matlab2tikz so I want to put that figure in my Latex document. I am using this code: \documentclass{article} \usepackage{tikz} \usepackage{graphicx} \usepackage{pgfplots} \begin{document} \begin{figure} \cent

• ### How to overlay multiple video files and merge all audio with ffmpeg?August 14

I overlay from 2 to 5 video files in a grid and I want to merge all the audio from each video. Here is my code to combine 3 video files. I think it works, but I get a warning I don't like. C:\ffmpeg.exe -i C:\Wildlife2.mp4 -i C:\Wildlife3.mp4 -i C:\W

• ### Split table into multiple files with \inputOctober 20

I want to split my table into multiple files: \input{table_head.tex} with following content \begin{table}[htpb] \centering \caption{Caption} \begin{tabular}[r]{ccc} \addlinespace \toprule A & B & C \\ \midrule \input{content1.tex} with following c

• ### Can not save PDF file with inputs, error message "Document is encrypted"January 16

I have inserted inputs to a form given as a PDF file. Using Evince document viewer 3.2.1 on Ubuntu 11.10, there is no problem with inserting inputs to the form and to print the result. But it is not possible to save the PDF file with inputs (as a new

• ### Using Batch Project Script to read from a text file as InputMay 29

I was wondering how I would modify the code of the Batch Project script shown below, to read from a text file of shapefile names as input. A sample of the textfile is shown under the code: #Import required modules import ConversionUtils, time #Define

• ### Write on a file and input itDecember 7

I'm trying to redefine a \tableofcontents-like command. I proceed this way : the displayed elements are written to a file, and the file is input when I want the display. If I know the toc will be called at the beginning (resp. the end) of the documen

• ### Multi-line text retrieved from file via \input, within a newcommand declaration, passing newly declared command as argument of standard letter classMay 21

I have put together a minimum working example consisting of a number of files mwe.tex % instance of personal letter address.tex % full address of individual being addressed in mwe.tex C:\LocalTeX\tex\latex\my\mygeneralmatter.sty % author's address an

• ### QTikZ Save standalone TikZ fileAugust 8

In QTikZ, it is possible to export a pdf, eps and png. I was wondering if it were possible to tell QTikZ to output a standalone TikZ file that is reading to add in a LaTeX document. So basically, QTikZ would have to merge both the template and the Ti

• ### Stored Procedure which accept xml file as inputSeptember 25

<?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price>

• ### Ideas for folder / file selector inputNovember 19

It works similarly to the file HTML input, but browses files or folders stored on the server, and it's mainly used to browse image gallery folders. I need some ideas on how to design the UI for it, before coding it. This is what I came up with so far

• ### Navigator package error: 'I can't find file yax' \input yax' March 6

With TeXLive 2013, under Linux Mint KDE 16, when I try to embed a file with the navigator package, I get the following errors pointing to navigator.tex and the source won't compile: line 14: I can't find file yax' \input yax line 14: Emergency stop

• ### find and replace multiple files using a file as input to find and another to replaceJuly 15

I need to replace several chunks of text inside some php scripts... i have: find . -name 'products.php' -exec grep --silent 'TEXT_TO_FIND' {} \; -exec ls {} \; -exec sed -i 's/TEXT_TO_FIND/REPLACE_TEXT/g' {} \; this work, but i have text of about 2 o