답변1
OP 요청 시 업데이트 2
from infty
의 간격을 나타 내기 위해 라는 새로운 스타일을 만들었습니다 -infinity
. 그림 아래에 텍스트를 배치하기 위해 경계 상자의 이름을 ax로 지정하고 그 아래에 노드를 배치했습니다.
from infty/.style args={#1of#2}{%<-- new style "from infty"
to path={($(\tikztostart)!#1!90:(\tikztotarget)$).. controls ($(\tikztostart)!1-#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. (\tikztotarget) \tikztonodes}}
\documentclass[tikz,border=5mm]{standalone}
%\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,quotes}
\begin{document}
\tikzset{my curve/.style args={#1of#2}{
to path={.. controls ($(\tikztostart)!#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
and ($(\tikztostart)!1-#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. (\tikztotarget)\tikztonodes}},
my curve/.default={7mm of 0.25},
to infty/.style args={#1of#2}{%<-- new style "to infty"
to path={.. controls ($(\tikztostart)!#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. ($(\tikztotarget)!#1!90:(\tikztotarget)$) \tikztonodes}},
from infty/.style args={#1of#2}{%<-- new style "from infty"
to path={($(\tikztostart)!#1!90:(\tikztotarget)$).. controls ($(\tikztostart)!1-#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. (\tikztotarget) \tikztonodes}},
to infty/.default={7mm of 0.4},
from infty/.default={7mm of 0.4}}
\begin{tikzpicture} [pics/tick/.style={code={\draw ++(0,-.2)node[below]{#1}--++(0,.4);}}]
\begin{scope}[local bounding box=axe]%<-- bounding box "axe"
\coordinate (z') at (-2,0);
\coordinate (c) at (1,0);
\coordinate (b) at (4,0);
\coordinate (a) at (6,0);
\coordinate (z) at (9,0);
\draw[-{Stealth[]}] (-2,0)--(10,0);
\pic at (c){tick=c};
\pic at (b){tick=b};
\pic at (a) {tick=a};
%\pic at (z) {tick};
\draw (z')to["4"{draw,circle},from infty](c) to["2"{draw,circle},my curve] (b) to ["3"{draw,circle},my curve] (a) to ["1"{draw,circle},to infty](z);
\end{scope}
\node[below] at (axe.south){My axis};%<-- node to add caption
\end{tikzpicture}
\end{document}
OP 요청에 따른 업데이트
to infty
무한대까지의 간격을 표현하기 위해 라는 새로운 스타일을 만들었습니다 . 그림 아래에 텍스트를 배치하기 위해 경계 상자의 이름을 지정 axe
하고 그 아래에 노드를 배치했습니다.
코드는 로 주석 처리되었습니다 %<--
.
\documentclass[tikz,border=5mm]{standalone}
%\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,quotes}
\begin{document}
\tikzset{my curve/.style args={#1of#2}{
to path={.. controls ($(\tikztostart)!#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
and ($(\tikztostart)!1-#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. (\tikztotarget)\tikztonodes}},
my curve/.default={7mm of 0.25},
to infty/.style args={#1of#2}{%<-- new style "to infty"
to path={.. controls ($(\tikztostart)!#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. ($(\tikztotarget)!#1!90:(\tikztotarget)$) \tikztonodes}},
to infty/.default={7mm of 0.4}}
\begin{tikzpicture} [pics/tick/.style={code={\draw ++(0,-.2)node[below]{#1}--++(0,.4);}}]
\begin{scope}[local bounding box=axe]%<-- bounding box "axe"
\coordinate (c) at (1,0);
\coordinate (b) at (4,0);
\coordinate (a) at (6,0);
\coordinate (z) at (9,0);
\draw[-{Stealth[]}] (0,0)--(10,0);
\pic at (c){tick=c};
\pic at (b){tick=b};
\pic at (a) {tick=a};
%\pic at (z) {tick};
\draw (c) to["2"{draw,circle},my curve] (b) to ["3"{draw,circle},my curve] (a) to ["1"{draw,circle},to infty](z);
\end{scope}
\node[below] at (axe.south){My axis};%<-- node to add caption
\end{tikzpicture}
\end{document}
곡선 매개변수
이 두 스타일은 기본적으로 설정되어 있으며 이전 그림과 같습니다. 수정이 가능합니다키곡선과 그곡률다음 매개변수를 사용합니다. 예를 들어 my curve=12mm of .4
곡선에 다음이 있음을 의미합니다.키그리고 12 mm
그제어점베지어 곡선의 위치는 경로에 0.4
있습니다 .1-0.4=0.6
\draw (c) to["2"{draw,circle},my curve=12mm of .4] (b) to ["3"{draw,circle},my curve=8mm of .2] (a) to ["1"{draw,circle},to infty=15mm of .6](z);
첫 번째 답변
재사용했어요내 곡선 7내가 여기에 쓴 코드. 이름을 바꿨습니다 my curve
.
\tikzset{my curve/.style args={#1of#2}{
to path={.. controls ($(\tikztostart)!#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
and ($(\tikztostart)!1-#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. (\tikztotarget)\tikztonodes}},
my curve/.default={7mm of 0.25}}
나는 pic
진드기를 그리고 그 아래에 텍스트를 쓸 수 있는 를 정의했습니다.
pics/tick/.style={code={\draw ++(0,-.2)node[below]{#1}--++(0,.4);}}
결과:
암호:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,quotes}
\begin{document}
\tikzset{my curve/.style args={#1of#2}{
to path={.. controls ($(\tikztostart)!#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
and ($(\tikztostart)!1-#2!(\tikztotarget)!#1!90:(\tikztotarget)$)
.. (\tikztotarget)\tikztonodes}},
my curve/.default={7mm of 0.25}}
\begin{tikzpicture} [pics/tick/.style={code={\draw ++(0,-.2)node[below]{#1}--++(0,.4);}}]
\coordinate (c) at (1,0);
\coordinate (b) at (4,0);
\coordinate (a) at (6,0);
\coordinate (z) at (9,0);
\draw[-{Stealth[]}] (0,0)--(10,0);
\pic at (c){tick=c};
\pic at (b){tick=b};
\pic at (a) {tick=a};
\pic at (z) {tick};
\draw (c) to["2"{draw,circle},my curve] (b) to ["3"{draw,circle},my curve] (a) to ["1"{draw,circle},my curve](z);
\end{tikzpicture}
\end{document}