2

I have nodes that are placed at specific positions in my Tikz picture, and I would like to put a plot next to it. To do this, I am using a shifted scope. However, when I change the shift values, nothing changes.

This is code with a simplified version of my problem:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}

\node at (2.7, -3.6) {Test};

\begin{scope}[x=4,y=1cm, shift={(3,-3.6)}]
    \tikz \draw[color=orange, domain=-2:2] plot (\x,{exp(-\x * \x)}) {};
\end{scope}

\end{tikzpicture}
\end{document}

Could you provide some guidance on how to fix this please?

3

Removing \tikz gets the job done :)

Output

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}

\node at (2.7, -3.6) {Test};
\begin{scope}[x=4,y=1cm, shift={(3,-3.6)}]
    \draw[color=orange, domain=-2:2] plot (\x,{exp(-\x * \x)}) {};
\end{scope}

\end{tikzpicture}
\end{document}
3

As @M. Al Jumaily already mentioned, the \tikz inside scope is incorrect (nesting tikz environments is always a bad idea).

Also, some of the packages in your preambel are not necessary (amsmath and pgfplots). Finally, one can avoid the scope environment. Therefore, I suggest the following simplification that makes the job you need.

Output

enter image description here

Code

\documentclass{article}

\usepackage{tikz}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[x=4,y=1cm]
\draw[color=orange,domain=-2:2,smooth]
    plot (\x,{exp(-\x * \x)})
    node[right,black,xshift=1cm] {Test};
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.