2

I try to draw this diagram: enter image description here

I write this code:

\documentclass[border=5pt]{standalone}

\usepackage{tikz}
\usepackage{siunitx}
\usetikzlibrary{quotes}
\usetikzlibrary{angles}
\usetikzlibrary{arrows}
\usetikzlibrary{automata}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}

\usepackage{amsmath,amsfonts,amssymb}


\begin{document}

\begin{tikzpicture}[line cap=round]

  % First, define nodes
\node[inner sep=0pt] (O1) at (0, 0) {};
\node[inner sep=0pt] (O2) at (0, 5) {};
\node[inner sep=0pt] (O3) at (5, 5) {};
\node[inner sep=0pt] (O4) at (5, 0) {};
\node[inner sep=0pt, label=$\boldsymbol{2}$] (A) at (1, 4) {};
\node[inner sep=0pt, label=$\boldsymbol{4}$] (A) at (2, 4) {};
\node[inner sep=0pt, label=$\boldsymbol{11}$] (A) at (3, 4) {};
\node[inner sep=0pt, label=$\boldsymbol{9}$] (A) at (4, 4) {};
\node[inner sep=0pt, label=$\boldsymbol{6}$] (A) at (1, 2.5) {};
\node[inner sep=0pt, label=$\boldsymbol{7}$] (A) at (2.5, 2.5) {};
\node[inner sep=0pt, label=$\boldsymbol{-1}$] (A) at (4, 2.5) {};
\node[inner sep=0pt, label=$\boldsymbol{-10}$] (A) at (1, 1) {};
\node[inner sep=0pt, label=$\boldsymbol{22}$] (A) at (2.5, 1) {};
\node[inner sep=0pt, label=$\boldsymbol{14}$] (A) at (4, 1) {};

\draw [line width=2pt, -] (O1) -- (O2);
\draw [line width=2pt, -] (O2) -- (O3);
\draw [line width=2pt, -] (O3) -- (O4);
\draw [line width=2pt, -] (O4) -- (O1);


%south east
%north west

\end{tikzpicture}

\end{document}

But I don't have any idea for drawing curve in it.

1 Answer 1

2

Something like that? You can add more coordinates for being more accurate with your curve and you can change the coordinates as you like to achieve the best curve shape you want. You can also use the option tension to make your curve more "loose" or more "stretched".

\documentclass[border=5pt]{standalone}

\usepackage{tikz}
\usepackage{siunitx}
\usetikzlibrary{quotes}
\usetikzlibrary{angles}
\usetikzlibrary{arrows}
\usetikzlibrary{automata}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}

\usepackage{amsmath,amsfonts,amssymb}


\begin{document}
    
    \begin{tikzpicture}[line cap=round]
        
        % First, define nodes
        \node[inner sep=0pt] (O1) at (0, 0) {};
        \node[inner sep=0pt] (O2) at (0, 5) {};
        \node[inner sep=0pt] (O3) at (5, 5) {};
        \node[inner sep=0pt] (O4) at (5, 0) {};
        \node[inner sep=0pt, label=$\boldsymbol{2}$] (A) at (1, 4) {};
        \node[inner sep=0pt, label=$\boldsymbol{4}$] (A) at (2, 4) {};
        \node[inner sep=0pt, label=$\boldsymbol{11}$] (A) at (3, 4) {};
        \node[inner sep=0pt, label=$\boldsymbol{9}$] (A) at (4, 4) {};
        \node[inner sep=0pt, label=$\boldsymbol{6}$] (A) at (1, 2.5) {};
        \node[inner sep=0pt, label=$\boldsymbol{7}$] (A) at (2.5, 2.5) {};
        \node[inner sep=0pt, label=$\boldsymbol{-1}$] (A) at (4, 2.5) {};
        \node[inner sep=0pt, label=$\boldsymbol{-10}$] (A) at (1, 1) {};
        \node[inner sep=0pt, label=$\boldsymbol{22}$] (A) at (2.5, 1) {};
        \node[inner sep=0pt, label=$\boldsymbol{14}$] (A) at (4, 1) {};
        
        \draw [line width=2pt, -] (O1) -- (O2);
        \draw [line width=2pt, -] (O2) -- (O3);
        \draw [line width=2pt, -] (O3) -- (O4);
        \draw [line width=2pt, -] (O4) -- (O1);
        
        
        %south east
        %north west
        
        \draw plot [smooth] coordinates {(2.5,0.8) (0.8,2.2) (0.9,3) (1.8,4.6) (3.3,4.4) (3.5,3.7) (3,1) (2.5,0.8)}; % <<<<<< 
        % this is the curve you can change it as you like by changing the coordinates.
        
    \end{tikzpicture}

enter image description here

You must log in to answer this question.

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