1

In the following plot

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows,shapes}

\begin{document}
\begin{tikzpicture}
    
    \node[draw,ultra thick,above right,] (USR) at (1,7) {User};
    \node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
    \draw[-latex,line width=1.mm,teal] (MNT.north) to[ out=120, in=210,] (USR.west);
    \draw[-latex,line width=1.mm,teal] (USR.east) to[ out=-30, in=50,] (MNT.east);
    %---
    \node[] (get) at (-1,4) {\large{GET}};
    % \node[below,yshift=-2mm] at (get) {\large{SET}};
    \node[] at (2,4) {\large{RESPONSE}};
    
\end{tikzpicture}
\end{document}

enter image description here

I cannot make the text GET, and RESPONSE be placed along the line (sloped). I have tested options pos=0.7, near end, or near start do not work. Finally, the words appear at coordinates to show this example.

5
  • please look up sloped text on this website
    – js bibra
    Commented Aug 16, 2021 at 14:29
  • @jsbibra yes, with \path does work as I was looking. I did not see the \path way of doing it :).
    – pablo
    Commented Aug 16, 2021 at 14:38
  • you could also go with this -- tex.stackexchange.com/a/210593/197451
    – js bibra
    Commented Aug 16, 2021 at 14:38
  • @jsbibra \path[-latex,line width=1.mm,teal] (MNT.north) [out=120, in=210,sloped] edge node [below] {GET} (USR.west);
    – pablo
    Commented Aug 16, 2021 at 14:39
  • please see the edit also
    – js bibra
    Commented Aug 16, 2021 at 14:45

2 Answers 2

1

enter image description here

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows,shapes}

\begin{document}
\begin{tikzpicture}
    
    \node[draw,ultra thick,above right,] (USR) at (1,7) {User};
    \node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
    \draw[-latex,line width=1.mm,teal] (MNT.north) to[ out=120, in=210,]node[above,sloped] (get)  {\large{GET}} (USR.west) ;
    \draw[-latex,line width=1.mm,teal] (USR.east) to[ out=-30, in=50,] (MNT.east);
    %---
    % \node[above,sloped] (get) at (-1,4) {\large{GET}};
    % \node[below,yshift=-2mm] at (get) {\large{SET}};
    % \node[] at (2,4) {\large{RESPONSE}};
    
\end{tikzpicture}
\end{document}

OR

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.arrows,shapes,decorations.text}

\begin{document}
\begin{tikzpicture}
    
    \node[draw,ultra thick,above right,] (USR) at (1,7) {User};
    \node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
    \draw[-latex,line width=1.mm,teal] (MNT.north) to[ out=120, in=210,]node[above,sloped] (get)  {\large{GET}} (USR.west) ;

    \def\myshift#1{\raisebox{1ex}}
    \draw[-latex,line width=1.mm,teal, postaction={decorate,decoration={text along path,text align=center,text={
    |\myshift|some bent text here}}}] (USR.east) to[ out=-30, in=50,] (MNT.east);
    %---
    % \node[above,sloped] (get) at (-1,4) {\large{GET}};
    % \node[below,yshift=-2mm] at (get) {\large{SET}};
    % \node[] at (2,4) {\large{RESPONSE}};
    
\end{tikzpicture}
\end{document}

enter image description here

2
  • How can I control the position, the distance between the two nodes? in the two types. I would like to place the text closer to User node
    – pablo
    Commented Aug 16, 2021 at 14:52
  • page 646 of the pgf manual here -- ctan.asis.ai/graphics/pgf/base/doc/pgfmanual.pdf
    – js bibra
    Commented Aug 16, 2021 at 15:50
1

If you want the text to follow the curve, you have to use the decorations.text library and some tricks, like in the following:

text along curve

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.text}

\begin{document}
    \begin{tikzpicture}

    \node[draw,ultra thick,above right,] (USR) at (1,7) {User};
    \node[draw,ultra thick,below] (MNT) at (-1,-2) {Management};
    
    \def\shft#1{\raisebox{1ex}} % Vertical shift to be used as an argument in the path decoration
    
    \draw[-latex,line width=1.mm,teal,postaction={decorate,decoration={text along path,text align=center,text={|\large\shft|GET SET}}}] (MNT.north) to[ out=120, in=210,] (USR.west);
    
    \draw[-latex,line width=1.mm,teal,postaction={decorate,decoration={text along path,text align=center,text={|\large\shft|RESPONSE}}}] (USR.east) to[ out=-30, in=50,] (MNT.east);
    \end{tikzpicture}
\end{document}
2
  • Seems like we wrote the same solution but js bibra beat me to it ;)
    – SebGlav
    Commented Aug 16, 2021 at 14:45
  • @SebGlab yes, it is a similar solution :-)
    – pablo
    Commented Aug 16, 2021 at 14:57

You must log in to answer this question.

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