4

In the example below, I want to align the text to the right of the tangent, as the scales are different, the tilt is wrong. I tried to use "transform shape" by the text becomes unreadable (too small), I can of course add a scale (different according to x and y) but it becomes a complicated code for not much.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {calc}
\usepackage{SIunitx}

\begin{document}

\begin{tikzpicture}[xscale=0.15,yscale=0.4]

\draw [thin,xstep=5,ystep=1,blue,dashed] (0,0) grid (50,12); \draw[-latex,thick] (0,0) -- (51,0) node[below]{$t$ en \si{\second}};

\draw[-latex, thick] (0,0) -- (0,13) node[above right]{$v$ en \si{\mm\per\second}};

\draw[domain=0:50] plot (\x,{8(1-exp(-\x/10))}); \draw[dashed,red,thick] (0,8)-- (50,8)node[above left]{$s_\infty=G\cdot U_0=\SI{8}{\mm/\second}$}; \draw[dashed,red,thick] (0,0) coordinate(O)-- node[sloped,above, pos=0.8]{Tangente en (0,0)}(10,8); \draw[thick, red] (10,0) -- (10, {8(1-exp(-1))}) coordinate(T0) -- (T0-|O)node[above]{$\num{0.63}\cdot G\cdot U_O$}; \node[below] at (10,0){10}; \node[left] at (0,10){10}; \end{tikzpicture}

\end{document}

enter image description here

rpapa
  • 12,350

2 Answers2

4

One way to do it is to use a decoration:

\draw[dashed,red,thick,
    postaction={decorate},
    decoration={
        markings,
        mark=at position 1.0 with {
            \node [blue, transform shape, anchor=base, shift={(10pt,2pt)}] 
                {Tangente en (0,0)};
        },
    },
] (0,0) coordinate(O) -- (10,8);

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {calc}
\usepackage{siunitx}
\usetikzlibrary{decorations.markings}

\begin{document} \begin{tikzpicture}[xscale=0.15,yscale=0.4]

\draw [thin,xstep=5,ystep=1,gray,dashed] (0,0) grid (50,12); \draw[-latex,thick] (0,0) -- (51,0) node[below]{$t$ en \si{\second}};

\draw[-latex, thick] (0,0) -- (0,13) node[above right]{$v$ en \si{\mm\per\second}};

\draw[domain=0:50] plot (\x,{8(1-exp(-\x/10))}); \draw[dashed,red,thick] (0,8)-- (50,8)node[above left]{$s_\infty=G\cdot U_0=\SI{8}{\mm/\second}$}; \draw[dashed,red,thick, postaction={decorate}, decoration={ markings, mark=at position 1.0 with { \node [blue, transform shape, anchor=base, shift={(10pt,2pt)}] {Tangente en (0,0)}; }, }, ] (0,0) coordinate(O) -- (10,8); \draw[thick, red] (10,0) -- (10, {8(1-exp(-1))}) coordinate(T0) -- (T0-|O)node[above, anchor=east]{$\num{0.63}\cdot G\cdot U_O$}; \node[below] at (10,0){10}; \node[left] at (0,10){10}; \end{tikzpicture}% \end{document}

Peter Grill
  • 223,288
3

The other way to do it is to fix \pgftransformlineattime.

One should also fix \pgftransformarcaxesattime and \pgftransformcurveattime following the same idea.

\documentclass{article}
\usepackage{tikz}

\makeatletter

\def\pgftransformlineattime#1#2#3{% \pgfgettransformentries\aa\ab\ba\bb\notimportantx\notimportanty%%% ⬅️⬅️⬅️ new \pgf@process{#2}% \pgf@xb=\pgf@x% xb/yb = start point \pgf@yb=\pgf@y% \pgf@process{#3}% \pgf@xc=\pgf@x% xc/yc = end point \pgf@yc=\pgf@y% \pgftransformshift{\pgfpointlineattime{#1}{\pgfqpoint{\pgf@xb}{\pgf@yb}}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}% \ifpgfresetnontranslationattime% \pgftransformresetnontranslations% \fi% \ifpgfslopedattime% \advance\pgf@xc by-\pgf@xb% \advance\pgf@yc by-\pgf@yb% % Now that we get the tangent vector without transformation % It suffices to apply the non-shift part of the transformation {%%% ⬇️⬇️⬇️ new \pgfsettransformentries\aa\ab\ba\bb{0pt}{0pt} \pgf@pos@transform{\pgf@xc}{\pgf@yc} \global\pgf@xc\pgf@xc \global\pgf@yc\pgf@yc }%%% ⬆️⬆️⬆️ new % OK, now xc and yc are correctly tangent to the line % Continue the usual routine \ifpgfallowupsidedownattime% \else% \ifdim\pgf@xc<0pt% \pgf@xc=-\pgf@xc% \pgf@yc=-\pgf@yc% \fi% \fi% \pgf@x=\pgf@xc% \pgf@y=\pgf@yc% \pgfpointnormalised{}% x/y = normalised vector \pgf@ya=-\pgf@y% \pgftransformcm% {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}% \fi% } \makeatother

\begin{document} \begin{tikzpicture}[xscale=2, yscale=3, xshift=40, yshift=50] \draw (0, 0) -- node[sloped, above] {sloped correctly?} (2, 2); \end{tikzpicture}% \end{document}

Symbol 1
  • 36,855