2

enter image description hereI just included matlab figures using matlab2tikz. I have annotations in my figures. These annotations are outside the plot area to prevent overlap with the data. But now I also want the annotations outside the plot in my latex file. If possible i want to implement it into the tikz file(not in the latex file).

I tried the following using `minipage

http://tex.stackexchange.com/questions/99224/putting-text-at-the-side-of-a-tikzpicture

setting clip=false (Didn't do anything)

Minipage worked but when i resized my plot in latex the annotations didn't scale and are now halve inside the plot.

using node[text width=6cm, anchor=west, right] at (5,0)
    {In this diagram, what can you say about $\angle F$, $\angle B$ and $\angle E$?};

from the same link (Didn't work)

I'm not very experienced with Tikz. I just tried some different methods, but none seems to work.

here is the tikz file:

    \begin{tikzpicture}
\begin{axis}[%
width=0.951\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=30,
xmax=330,
xlabel={$\text{T}_{\text{surr}}\text{ (K)}$},
ymin=0,
ymax=120,
ylabel={$\text{Q}_{\text{Cooling}}\text{ (W)}$},
axis background/.style={fill=white},
title style={font=\bfseries},
title={Cooling power for surrounding temperatures},
axis x line*=bottom,
axis y line*=left
]
\addplot [color=mycolor1,solid,forget plot]
  table[row sep=crcr]{%
30  6.97463548006898\\
60  7.00516177264937\\
90  7.36872538108224\\
120 8.92825821383692\\
150 12.7097699247381\\
180 19.3898073983116\\
210 29.107506124354\\
240 42.0222333872511\\
270 58.3725938451868\\
300 78.4696582472676\\
330 102.691450312509\\
};
\end{axis}

\begin{axis}[%
width=1.227\figurewidth,
height=1.227\figureheight,
at={(-0.16\figurewidth,-0.135\figureheight)},
scale only axis,
xmin=0,
xmax=1,
ymin=0,
ymax=1,
hide axis,
axis x line*=bottom,
axis y line*=left
]
**\node[below right, align=left, text=black, draw=black]
at (rel axis cs:0.75,0.15) {G10 \\$\text{ }\epsilon\text{ = 1 }$\\ F = 1 \\$\text{ T}_{\text{start}}\text{ = 330 }$\\$\text{ T}_{\text{end}}\text{ = 30 }$\\$\text{ dT}_{\text{max}}\text{ = 1 }$\\ N = 100};**
\end{axis}
\end{tikzpicture}%
4
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Commented Nov 25, 2015 at 10:46
  • Sorry, where is tikz file?
    – Zarko
    Commented Nov 25, 2015 at 12:18
  • I added the tikzfile code
    – fahrenheiz
    Commented Nov 25, 2015 at 12:26
  • There's still no MWE (starting with \documentclass{...} and ending with \end{document}).
    – jarauh
    Commented Nov 25, 2015 at 15:22

1 Answer 1

1

Your code works if you add clip=false to the second axis environment, containing the node with the annotation. Having done that you can just move it to the position of your choice, by changing the coordinates for the \node.

That said, the second axis environment is not really necessary here, you might as well add it inside the first axis environment, or right outside it, placing it relative to the axis.

In the code below both options are demonstrated. Note that I've added name=MyAxis to the axis options, and the node is placed at MyAxis.north east. I don't know what G10 is, but it seemed like it was a heading of sorts, hence the bold text. Of course, remove that \textbf if you don't want it. I also set the list of values using aligned.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots,amsmath}
\newlength{\figurewidth}
\setlength{\figurewidth}{10cm}
\newlength{\figureheight}
\setlength{\figureheight}{5cm}

\begin{document}
\begin{tikzpicture}
\begin{axis}[%
name=MyAxis,
width=0.951\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=30,
xmax=330,
xlabel={${T}_{\text{surr}}\text{ (K)}$},
ymin=0,
ymax=120,
ylabel={$\text{Q}_{\text{Cooling}}\text{ (W)}$},
axis background/.style={fill=white},
title style={font=\bfseries},
title={Cooling power for surrounding temperatures},
axis x line*=bottom,
axis y line*=left,
%clip=false %uncomment this if you want the annotation outside the axis
]
\addplot [color=blue,solid,forget plot]
  table[row sep=crcr]{%
30  6.97463548006898\\
60  7.00516177264937\\
90  7.36872538108224\\
120 8.92825821383692\\
150 12.7097699247381\\
180 19.3898073983116\\
210 29.107506124354\\
240 42.0222333872511\\
270 58.3725938451868\\
300 78.4696582472676\\
330 102.691450312509\\
};

\node[below right, align=center, text=black]
at (rel axis cs:0.1,0.9) {\textbf{G10} \\
$\begin{aligned} 
\epsilon &= 1\\
 F &= 1 \\
T_{\text{start}} &= 330 \\
T_{\text{end}} &= 30\\
\mathrm{d}T_{\text{max}}&= 1\\
 N &= 100
\end{aligned}$};

\end{axis}

\node[below right, align=center, text=black]
at (MyAxis.north east) {%
\textbf{G10} \\
$\begin{aligned} 
\epsilon &= 1\\
 F &= 1 \\
T_{\text{start}} &= 330 \\
T_{\text{end}} &= 30\\
\mathrm{d}T_{\text{max}}&= 1\\
 N &= 100
\end{aligned}$};
\end{tikzpicture}%
\end{document}
8
  • Torbjorn, Thanks a lot for explaining and also showing that i need only 1 axis. The second axes is probably because i added the annotations inside matlab. Only one question remains. I get a error message (see image in post) when i dont remove everything above \begin{tikzpicture} and below \end{tikzpicture}. Is the rest to save at as a tex. file and externalise the image to prevent exceeding the Tex capacity? This happens if i add a different picture. But I have'n't figure out how to load .tex file if i save it like that, because \begin{figure}[htb] \input{mysphere.tex} \end{figure}
    – fahrenheiz
    Commented Nov 26, 2015 at 8:55
  • @fahrenheiz I don't fully understand. To use it as \begin{figure}\input{file.tex}\end{figure}, file.tex cannot contain a \documentclass, the preamble and document environment, it should only contain the tikzpicture environment. Commented Nov 26, 2015 at 9:34
  • The script is an external tikz or tex file. The begin figure,input is to include into my main tex file which is a report with the different graphs. But this doesn't seem to work for most images because the Tex capapacity is exceeded.
    – fahrenheiz
    Commented Nov 26, 2015 at 9:49
  • I get now that the \documentclass is only for the main document, but looking around this capacity error i see that most people don't use matlab2tikz but only use the data from matlab and do the plotting in a different way.
    – fahrenheiz
    Commented Nov 26, 2015 at 9:52
  • @fahrenheiz That can happen with large datafiles, but is unrelated to the error you show in the image. Externalisation doesn't help? Can you compile with lualatex instead of pdflatex? Commented Nov 26, 2015 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .