我正在尝试制作一个需要两个箭头的图形,我已经找到了如何旋转箭头,但我不想将文本旋转 180 度。
Bonusproblem,我想要红线行情机......
\documentclass[10pt,a4paper]{article}
\usepackage[dutch]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc, trees, positioning, arrows, shapes, shapes.multipart, shadows, matrix, decorations.pathreplacing, decorations.pathmorphing}
\usepackage{enumitem}
\setlist{itemsep=0pt}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{tikzpicture}
\tkzInit[ymin=0,ymax=9,xmin=0,xmax=14]
\tkzClip
\tkzDefPoints{1/1/A, 1/7/Y, 13/1/X, 1/2/B, 13/2/E, 7/2/K, 7/6.3/L, 4/5/J, 10/5/M, -2/2.5/C, 16/2.5/D}
\draw[->, very thick] (A) -- (Y) node[above, yshift=-1cm, xshift=-0.3cm, rotate=90] {effectiviteit};
\draw[->, very thick] (A) -- (X) node[below, xshift=-0.4cm, yshift=-0.3cm] {stress (+)};
\draw[very thick, red] plot [smooth] coordinates {(B) (J) (L) (M) (E)};
\node[single arrow, rounded corners=3pt, fill=blue!30, draw, align=center, xshift=3cm, yshift=2.5cm, minimum height=4cm, minimum width=2cm]{Concentratie \\ Inspanning };
\node[single arrow, rounded corners=3pt, fill=red!30, draw, align=center, xshift=11cm, yshift=2.5cm, rotate=180, minimum height=4cm, minimum width=2cm]{Relaxatie \\ Ontspanning};
\end{tikzpicture}
\end{center}
\end{document}
答案1
rotate=180
您可以使用而不是shape border rotate=180
。要获得更粗的红线,您可以应用ultra thick
甚至指定精确的厚度line width=<size>
(正如我下面所做的那样)。
但正如你从上面看到的,如果红线太粗,两端看起来不太好,与垂直轴的交点也不太好看。这可以通过使用line cap=round
和白垩轴的重叠部分得到:
您可以通过对每个坐标应用移位来绘制另一条线(但不确定为什么 不起作用scope
)。为了使所需的箭头可见,我添加了shorten >=-0.4cm
,这样线条的箭头就不会被大的旋转箭头遮挡。
笔记:
- 我还替换了
center
环境,\centering
以消除垂直空间何时应使用 \begin{center} 而不是 \centering?。
代码:
\documentclass[10pt,a4paper]{article}
\usepackage[dutch]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc, trees, positioning, arrows, shapes, shapes.multipart, shadows, matrix, decorations.pathreplacing, decorations.pathmorphing}
\usepackage{enumitem}
\setlist{itemsep=0pt}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{tikzpicture}
\tkzInit[ymin=0,ymax=9,xmin=0,xmax=14]
\tkzClip
\tkzDefPoints{1/1/A, 1/7/Y, 13/1/X, 1/2/B, 13/2/E, 7/2/K, 7/6.3/L, 4/5/J, 10/5/M, -2/2.5/C, 16/2.5/D}
\draw[line width=5pt, line cap=round, red] plot [smooth] coordinates {(B) (J) (L) (M) (E)};
\node[single arrow, rounded corners=3pt, fill=blue!30, draw, align=center, xshift=3cm, yshift=2.5cm, minimum height=4cm, minimum width=2cm]{Concentratie \\ Inspanning };
\node[single arrow, rounded corners=3pt, fill=red!30, draw, align=center, xshift=11cm, yshift=2.5cm, shape border rotate=180, minimum height=4cm, minimum width=2cm, ]{Relaxatie \\ Ontspanning};
%% Fill out the overflow of the really thick red line
\fill[white] (A) rectangle ($(A)+(-3.0em,2.0cm)$);
%% Move to be after so that the axis is on top of the thick red line
\draw[->, very thick] (A) -- (Y) node[above, yshift=-1cm, xshift=-0.3cm, rotate=90] {effectiviteit};
\draw[->, very thick] (A) -- (X) node[below, xshift=-0.4cm, yshift=-0.3cm] {stress (+)};
\end{tikzpicture}
\end{center}
\end{document}
代码:第二行和箭头:
\documentclass[10pt,a4paper]{article}
\usepackage[dutch]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{calc, trees, positioning, arrows, shapes, shapes.multipart, shadows, matrix, decorations.pathreplacing, decorations.pathmorphing}
\usepackage{enumitem}
\setlist{itemsep=0pt}
\usepackage{graphicx}
\tikzset{My Shift/.style={yshift=0.75cm}}
\begin{document}
{\centering%
\begin{tikzpicture}
\tkzInit[ymin=0,ymax=9,xmin=0,xmax=14]
\tkzClip
\tkzDefPoints{1/1/A, 1/7/Y, 13/1/X, 1/2/B, 13/2/E, 7/2/K, 7/6.3/L, 4/5/J, 10/5/M, -2/2.5/C, 16/2.5/D}
\draw[line width=5pt, line cap=round, red, -latex, shorten >=-0.4cm] plot [smooth] coordinates {(B) (J) (L) (M) (E)};
\draw[line width=5pt, line cap=round, blue, -latex, shorten >=-0.4cm] plot [smooth] coordinates {([My Shift]B) ([My Shift]J) ([My Shift]L) ([My Shift]M) ([My Shift]E)};
\node[single arrow, rounded corners=3pt, fill=blue!30, draw, align=center, xshift=3cm, yshift=2.5cm, minimum height=4cm, minimum width=2cm]{Concentratie \\ Inspanning };
\node[single arrow, rounded corners=3pt, fill=red!30, draw, align=center, xshift=11cm, yshift=2.5cm, shape border rotate=180, minimum height=4cm, minimum width=2cm, ]{Relaxatie \\ Ontspanning};
%% Fill out the overflow of the really thick red line
\fill[white] (A) rectangle ($(A)+(-3.0em,2.0cm)$);
%% Move to be after so that the axis is on top of the thick red line
\draw[->, very thick] (A) -- (Y) node[above, yshift=-1cm, xshift=-0.3cm, rotate=90] {effectiviteit};
\draw[->, very thick] (A) -- (X) node[below, xshift=-0.4cm, yshift=-0.3cm] {stress (+)};
\end{tikzpicture}}
\end{document}