I have got a file to plot with pgfplots. For convenience I'd like to define a measure in the plot. Unfortunately the relative positioning seems to give weird results. If I define the node coordinates manually everything works fine. According to the pgfplots
-manual the sin- and cos-operators use degrees. Could you please tell me where my error is?
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usepackage{siunitx}
\pgfplotsset{compat=1.10}
\begin{document}
\pgfplotsset{cellmodel/.style={%
width=0.4\linewidth,
height=0.3\textheight,
axis lines=center,
axis equal image,
domain=0:800,
xmin= 0, xmax= 7,
ymin=-1.5, ymax=6.5,
restrict x to domain=0:7,
ticks=none,
}}
\begin{tikzpicture}
\def\angle{-30}
\begin{axis}[cellmodel]
\addplot[mark=x, mark options={solid}, draw=gray!80!black, dashed, thick] coordinates {
(0.0,0.5)
(2.25,0.5)
(4.5,4.397114317029974)
(6.75,4.397114317029974)
};
% necessary nodes
\node (two) at (axis cs:2.25,0.5) {};
\node (thr) at (axis cs:4.5,4.397114317029974) {};
% relative nodes
% \node (mes2l) at ($(two)+({cos(\angle)},{sin(\angle)})$) {test}; % <- doesn't give the correct coordinates
% \node (mes3l) at ({$(thr)+({cos(\angle)},{sin(\angle)})$}) {test};
% \node (mes2l) at ($(two)+(axis cs:{cos(\angle)},{sin(\angle)})$) {test}; % <- doesn't give the correct coordinates
% \node (mes3l) at ({$(thr)+(axis cs:{cos(\angle)},{sin(\angle)})$}) {test};
\node (mes2l) at (axis cs:3.116025404,0) {}; % <- correct coordinates
\node (mes3l) at (axis cs:5.366025404,3.897114317) {};
\draw[<->] (mes2l.center) -- (mes3l.center) node [below right, midway]{$l$};
\end{axis}
\end{tikzpicture}
\end{document}
sin 30
to0.5
would result in ay=0
? You have\node (two) at (axis cs:2.25,0.5)
and\node (mes2l) at ($(two)+(axis cs:{cos(30)},{sin(30)})$)
. – Peter Grill Apr 3 '14 at 20:07-30°
. This must have been switched around during all the trial and error runs. – raedma Apr 4 '14 at 8:55