在 tikz 中更改轴缩放和翻转花括号

在 tikz 中更改轴缩放和翻转花括号

我试图绘制一个轴,上面有特定的点,上面和下面有花括号来强调某些间隔。目标是画出下面我勾勒出的图像:

目标草图

我有一个接近但非常糟糕的结果。首先,花括号的方向不正确。而且它被夹得很紧,很小,整体看起来很糟糕。这是我目前的结果,下面是它的代码:

姆韦

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{center}
\begin{tikzpicture}[decoration={calligraphic brace, amplitude=6pt}]
 \draw (-1,0) -- (4,0);
 \foreach \Point/\PointLabel in {(0,0)/a_0, (3.1415,0)/b_0, (1.5707,0)/b_1, (0.7853,0)/a_2}
        \draw[fill=black] \Point circle (0.05) node[above] {$\PointLabel$};
 \foreach \Point/\PointLabel in {(0,0)/a_1, (1.5707,0)/b_2, (0.7853,0)/a_2}
        \draw[fill=black] \Point circle (0.05) node[below] {$\PointLabel$};
 \draw[decorate,thick] (0,-0.8) -- node[below=1ex](I0){$I_0$} (3.1415,-0.8);
 \draw[decorate,thick] (0,-0.4) -- node[below=1ex]{$I_1$} (1.5707,-0.4);
 \draw[decorate,thick] (0.7853,0.4) -- node[above=1ex]{$I_2$} (1.5707,0.4);
\end{tikzpicture}
\end{center}
\end{document}

我认为可以让所有东西分开以使其看起来更好的一种方法是改变坐标,而不是从 -1 到 4,而是从 -5 到 5 或其他什么的,但理想情况下我尽量不要这样做,如果可能的话,因为 a_i 和 b_i 是一个序列的项,所以它们有一个固定的值,即使该值没有出现在图表上。

答案1

  1. 正如前面提到的,您可以使用 键mirror来镜像括号。或者,您也可以交换起始和结束坐标。
  2. 为了“解开”图表,您可以增加 x 单位。这可以通过添加xscale=factor或来实现x=<length。下面我使用x=2cm
  3. piTi 已知Z。
  4. 您可以使循环更加符合人体工程学,特别是为可用于括号的节点提供名称。
  5. 要找到适合支架的垂直坐标,您可以使用current bounding box不断更新的节点。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{center}
\begin{tikzpicture}[x=2cm]
 \draw (-1,0) -- (4,0);
 \path foreach \X/\Y/\Z  in 
  {0/a_0/a_1, pi/b_0/, {pi/2}/b_1/b_2,{pi/4}/a_2/a_2}
     { (\X,0) node[circle,fill,inner sep=0.5mm,
        label=above:{$\Y$},label=below:{$\Z$},alias=\Z] (\Y) {}};
 \begin{scope}[thick,decoration={calligraphic brace, amplitude=6pt}]
  \draw[decorate]   (current bounding box.north) coordinate (aux)
    (a_2|-aux) -- node[above=1ex]{$I_2$} (b_1|-aux);
  \draw[decorate]   (current bounding box.south) coordinate (aux)
    (b_1|-aux) -- node[below=1ex]{$I_1$} (a_0|-aux);
  \draw[decorate]   (current bounding box.south) coordinate (aux)
    (b_0|-aux) -- node[below=1ex]{$I_0$} (a_0|-aux);
 \end{scope} 
\end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

答案2

牙套需要镜像选项来反转——使用它后你就能看到下牙套的效果

由于您对所有三个括号都应用了一个通用选项,因此很难区分反转 - 因此我感觉最好为所有三个括号使用单独的命令,如下例所示

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}
\begin{center}
\begin{tikzpicture}[decoration={calligraphic brace, mirror, amplitude=6pt}]
 \draw (-1,0) -- (4,0);
 \foreach \Point/\PointLabel in {(0,0)/a_0, (3.1415,0)/b_0, (1.5707,0)/b_1, (0.7853,0)/a_2}
        \draw[fill=black] \Point circle (0.05) node[above] {$\PointLabel$};
 \foreach \Point/\PointLabel in {(0,0)/a_1, (1.5707,0)/b_2, (0.7853,0)/a_2}
        \draw[fill=black] \Point circle (0.05) node[below] {$\PointLabel$};
 \draw[decorate,thick] (0,-0.8) -- node[below=1ex](I0){$I_0$} (3.1415,-0.8);
 \draw[decorate,thick] (0,-0.4) -- node[below=1ex]{$I_1$} (1.5707,-0.4);
 \draw[decorate,thick] (0.7853,0.4) -- node[above=1ex]{$I_2$} (1.5707,0.4);
\end{tikzpicture}
\par \vspace*{3cm}
\tikz[baseline, remember picture] \node[inner sep = 0pt, anchor = base] (mainclause) {She said}; 
\tikz[baseline, remember picture] \node[inner sep = 0pt, anchor = base] (subclause) {that he knows}; 
\begin{tikzpicture}[remember picture, overlay]
\draw[decorate, decoration ={brace,raise=1pt}] (subclause.north west) -- (subclause.north east)
node (subclauselabel) [midway, above=1pt] {\footnotesize{Subordinate clause}};
\draw[decorate, decoration = brace] (mainclause.north west |- subclauselabel.north west) -- (subclauselabel.north east)
node [midway, above] {\footnotesize{Main clause}};
\end{tikzpicture}
\end{center}
\end{document}

答案3

尝试以下代码,并根据您的需要进行编辑。

请注意,要反转括号请使用, mirror选项。

另外,为了使其垂直,使用-- +(90:1.6)-- +(-90:1.6)相应地

\draw [violet, decorate,decoration={brace,amplitude=.2cm, mirror}, xshift=0cm, yshift=0cm] (0,-0.4) -- +(0:1.6) node [violet, midway, xshift=0cm, yshift=-.45cm] {\footnotesize $I_1$};

\draw [violet, decorate,decoration={brace,amplitude=.2cm, mirror}, xshift=0cm, yshift=0cm] (0,-0.94) -- +(0:3.16) node [violet, midway, xshift=0cm, yshift=-.5cm] {\footnotesize $I_0$};

得到下图

在此处输入图片描述

相关内容