在 Latex 中绘制带边缘区域的函数

在 Latex 中绘制带边缘区域的函数

有没有一种简单的方法可以在 Latex 中绘制类似右侧图像的内容?显示“铰链损失”但铰链损失函数不应该出现。或者它太复杂而无法通过编程绘制? 在此处输入图片描述

编辑:

我自己完成了图像的某些部分:

\begin{tikzpicture}
\scriptsize
  \draw[thick] (3,0) -- (11,0);
  \draw[shift={(5.5,0)},color=black] (0pt,3pt) -- (0pt,-3pt);
  \draw[shift={(5.5,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below]
  {$-1$};
  \draw[shift={(7,0)},color=black] (0pt,3pt) -- (0pt,-3pt);
  \draw[shift={(7,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below]
  {$0$};
  \draw[shift={(8.5,0)},color=black] (0pt,3pt) -- (0pt,-3pt);
  \draw[shift={(8.5,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below]
  {$1$};
  \draw (4.5,-2) -- (6.5,2);
  \draw[red,thick] (6,-2) -- (8,2);
  \draw (7.5,-2) -- (9.5,2);

  \foreach \Point in {(3.5,-1.3), (5.3,2), (4.5,1), (4.7,-1.2), (5,-0.3)}{
    \node at \Point {-};};

  \foreach \Point in {(8.7,-1), (9.7,1.5), (8.9,-0.3), (10,-1.2)}{
    \node at \Point {+};};

  \draw[text=blue,decoration={brace,mirror,raise=5pt},decorate]
  (3,-2) -- node[below=6pt] {Wrong prediction} (5.9,-2);

  \draw[text=blue,decoration={brace,mirror,raise=5pt},decorate]
  (6,-2) -- node[below=6pt] {Too close} (7.4,-2);

  \draw[text=blue,decoration={brace,mirror,raise=5pt},decorate]
  (7.5,-2) -- node[below=6pt] {Correct prediction} (11,-2);

\end{tikzpicture}

不过,我不知道如何填充(绘制)线条之间的区域。

相关内容