带 tikz 的复杂图形

带 tikz 的复杂图形

我正在尝试使用 tikz 创建以下图片在此处输入图片描述

我找到了这段代码,它输出的结果与我想要的结果类似:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows ,calc}

\tikzset{
    modal/.style={>=stealth’,shorten >=1pt,shorten <=1pt,auto,node distance=1.5cm,
        semithick},
    world/.style={circle,draw,minimum size=0.5cm,fill=gray!15},
    point/.style={circle,draw,inner sep=0.5mm,fill=black},
    reflexive above/.style={->,loop,looseness=7,in=120,out=60},
    reflexive below/.style={->,loop,looseness=7,in=240,out=300},
    reflexive left/.style={->,loop,looseness=7,in=150,out=210},
    reflexive right/.style={->,loop,looseness=7,in=30,out=330}
}
\begin{document}


\begin{tikzpicture}[modal,node distance=4cm]
\node (A) {A};
\node (E) [right=of A] {E};
\node (I) [below=of A] {I};
\node (O) [below=of E] {O};
\coordinate (CENTER) at ($(A)!0.5!(O)$);
\node (contra) at (CENTER) {contradictory};
\path[<->] (A) edge node[above] {contrary} (E);
\path[<->] (I) edge node[below] {subcontrary} (O);
\path[->] (A) edge node[above,rotate=90] {subaltern} (I);
\path[->] (E) edge node[above,rotate=-90] {subaltern} (O);
\path[->] (contra) edge (A);
\path[->] (contra) edge (E);
\path[->] (contra) edge (I);
\path[->] (contra) edge (O);
\end{tikzpicture}

\end{document}

问题是我不知道如何在不改变箭头指向的情况下在节点附近添加一些文本。

此外,我收到此错误:包 pgf 错误:未知箭头提示类型“隐身”。

答案1

提示您的代码:使用>=stealth'而不是>=stealth’来实现最小的工作示例。

您可以使用:

  • shorten >=0.1cm或者shorten <=0.1cm将两端的箭头短接成规定的长度(例如0.1这里)
  • label=west:your text用于标记(your text)不同方向的节点(west,,east...)
  • \node[left=0cm and 0cm of A,节点相对于的位置A
  • 更多坐标,例如\coordinate (EAST) at ($(E)!0.5!(O)$);\coordinate (SOUTH) at ($(I)!0.5!(O)$);将文本放置在节点附近
  • 路径颜色,只是\path[blue,->]…… 在此处输入图片描述

梅威瑟:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{positioning,arrows,calc}
\tikzset{
modal/.style={>=stealth',shorten >=1pt,shorten <=1pt,auto,node distance=1.5cm,
semithick},
world/.style={circle,draw,minimum size=0.5cm,fill=gray!15},
point/.style={circle,draw,inner sep=0.5mm,fill=black},
reflexive above/.style={->,loop,looseness=7,in=120,out=60},
reflexive below/.style={->,loop,looseness=7,in=240,out=300},
reflexive left/.style={->,loop,looseness=7,in=150,out=210},
reflexive right/.style={->,loop,looseness=7,in=30,out=330}
}

\begin{document}
\begin{tikzpicture}[modal,node distance=4cm]
\node(A) {A};
\node(E) [right=of A] {E};
\node(I) [below=of A] {I};
\node(O) [below=of E] {O};
\coordinate (CENTER) at ($(A)!0.5!(O)$);
\coordinate (NORTH) at ($(A)!0.5!(E)$);
\coordinate (WEST) at ($(A)!0.5!(I)$);
\coordinate (EAST) at ($(E)!0.5!(O)$);
\coordinate (SOUTH) at ($(I)!0.5!(O)$);
\node (contra) at (CENTER) {text};
\path[blue,->] (A) edge node[left,rotate=0] {} (I);%90
\path[->] (E) edge node[right,rotate=0] {} (O);%-90
\path[shorten <=0.2cm,->] (contra) edge (A);
\path[shorten <=0.2cm,->] (contra) edge (E);
\path[shorten <=0.2cm,->] (contra) edge (I);
\path[shorten <=0.2cm,->] (contra) edge (O);
\path[shorten >=0.5cm,shorten <=0.5cm,->] (contra) edge (EAST);
\path[shorten >=0.5cm,shorten <=0.5cm,->] (contra) edge (WEST);
%
\node (contra) at (NORTH) {text};
\node (pro) at (SOUTH) {text};
%
\path[shorten >=0.3cm,shorten <=0.5cm,->] (contra) edge (E);
\path[shorten >=0.3cm,shorten <=0.5cm,->] (contra) edge (A);
%
\path[->] (pro) edge (I);
\path[->] (pro) edge (O);
%
\node[left=0cm and 0cm of A, label=west:text] {(1)};
\node[left=0cm and 0cm of I, label=west:text] {(1)};
\node[left=0cm and 0cm of WEST, label=west:text] {(0.5)};
\node[right=0cm and 0cm of E, label=east:text] {(1)};
\node[right=0cm and 0cm of O, label=east:text] {(1)};
\node[right=0cm and 0cm of EAST, label=east:text] {(-0.5)};
\end{tikzpicture}
\end{document}

相关内容