4

With this MWE:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit,calc}
\makeatletter
\tikzset{
  % http://tex.stackexchange.com/questions/47704/how-to-establish-node-anchor
  fitting node/.style={
    inner sep=0pt,
    fill=none,
    draw=none,
    reset transform,
    fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)}
  },
  reset transform/.code={\pgftransformreset},
}
\makeatother

\begin{document}
\begin{tikzpicture}
% separately plot and box, else tikzedt don't show handles
\draw [black,thick] (1,3) rectangle (3.5,4)
  node[fitting node] (mynode) {};
%/* % also make tikzedt ignore (do not parse) this, plot kills all handles
\draw let \p1=(mynode) in
  [black, thick, domain=0:2.5,samples=50]
  plot (\x,{0.5*exp(-\x)*sin(1000*\x)});
%*/
\end{tikzpicture}
\end{document}

... I get this:

test.png

I'm using tikzedt, and with that kind of syntax, it gives me handles to move the rectangle node around; I'd like to have the plot part inside it, so it moves along with the node.

Unfortunately, the \draw plot crashes gives entirely wrong results if it encounters \x1 or \y1 which would result from a let operation (e.g. as in plot ({\x1+\x},{\y1+0.5*exp(-\x)*sin(1000*\x)});).

So, how can I move the \draw plot inside the (mynode) (that is, make it's positioning in reference to (mynode), instead of explicit)?

5

Well, could have just used shift, wish I remembered earlier:

\draw let \p1=(mynode.west) in
  [black, thick, domain=0:2.5,samples=50,shift=(\p1)]
  plot ({\x},{0.5*exp(-\x)*sin(1000*\x)});

test.png

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.