我正在尝试绘制图中的“扭曲”曲线:
我不是 Tikz 专家,我编写了以下 Latex 代码:
\documentclass{standalone}
\pagestyle{empty}
\usepackage{tikz}
\usepackage{verbatim}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.markings} %% Add decoration library
%\usetikzlibrary{knots}
%\renewcommand{\baselinestretch}{2}
\pagestyle{plain}
\begin{document}
% SET ARROW STYLE WITH TIP IN THE MIDDLE OF THE LINE
\tikzset{->-/.style={decoration={
markings,
mark=at position -0.3 with {\arrow{>}}},postaction={decorate}}}
\tikzset{line/.style={->,shorten <=0.4cm,shorten >=0.4cm}}
\centering
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}[auto, node distance=5cm,>=latex']
% DRAW AXIS
\draw[->](-2,0)--(3,0);
\draw[->](0,-2)--(0,4);
\node at(3.2,0)(x){\large$x$};
\node at(0.25,4)(xy){\large$\dot{x}$};
% DRAW CURVES
\draw[->-] (0,3) .. controls (-0.001,2) and (1.9,-1) .. (0,-0.5);
\draw[-] (0,-0.5) .. controls (-0.1,-0.08) and (-0.3,-0.2) .. (-0.25,0);
\draw[-] (-0.25,0) .. controls (-0.1,0.4) and (0,0) .. (0.05,0);
\draw[-] (0.05,0) .. controls (0.1,-0.2) and (0.05,-0.2) .. (0,-0.03);
\node at(0.2,0.2)(x){\large$0$};
\end{tikzpicture}
}%
\end{document}
我可以改进我的代码吗?谢谢!
答案1
我稍微修改了你的代码。我删除了一些不需要的命令,并修改了曲线的点以适应模型。
注释备注。 0 是实数。我认为你需要字母哦来表示起源。
代码:
\documentclass[margin=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, decorations.markings}
\begin{document}
% SET ARROW STYLE WITH TIP IN THE MIDDLE OF THE LINE
\tikzset{%
->-/.style={%
decoration={
markings,
mark=at position .65 with {\arrow[scale=1.2]{stealth}}
},
postaction={decorate}
},
>=stealth
}
\begin{tikzpicture}
% DRAW AXIS
\draw[->] (-1, 0) -- (2, 0) node[above right] {$x$};
\draw[->] (0, -1.5) -- (0, 4) node[left] {$\dot{x}$};
% DRAW CURVE
\draw[blue, thick, ->-] (0, 3)
to[out=270, in=90] (1, 0)
.. controls +(0, -.4) and (.8, -1.1) .. (.4, -1.1)
.. controls +(-.2, 0) and (0, -.8) .. (0, -.5)
.. controls +(0, .3) and (-.2, -.2) .. (-.2, 0)
.. controls +(0, .2) and (0, .25) .. (0, 0);
\path (0, 0) node[above right] {$O$};
\end{tikzpicture}
\end{document}