使用 fillbetween 为区域着色

使用 fillbetween 为区域着色

我想知道如何使用\fillbetween以下内容:

在此处输入图片描述

我需要改变“弱可解”和“不可解”区域的颜色。

\documentclass[border=2pt]{standalone}

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections}
\usetikzlibrary{automata,positioning,shapes}
\begin{document}

    \begin{tikzpicture}
    \node at (2,4) {\textbf{Weakly solvabale}};
    \draw[name path = line] (4,5) -- (4,0);
    \draw [rounded corners=15pt] (0,0) rectangle ++(7,5);
    \draw[name path = circle, fill=LimeGreen] (2,1.7) circle [radius=1.2cm] node {\textbf{Solvable}};
    \node at (5.5,2.5) {\textbf{Unsolvabale}};
    of=line and circle,
    soft clip={domain=-3:3}
    ];
    \begin{pgfonlayer}{bg}
    \fill [orange!50,
    intersection segments={
        of=circle and line
    }];
    \end{pgfonlayer}
    \end{tikzpicture}

\end{document}  

答案1

首先我们使用一个水平分割节点,左侧部分顶部对齐。然后我们在左侧部分内绘制一个圆形节点。就这样。

\documentclass[border=2pt, tikz, dvipsnames]{standalone}
\usetikzlibrary{positioning,shapes.multipart}
\begin{document}

    \begin{tikzpicture}

    \node[rectangle split,
            rectangle split horizontal,
            rectangle split parts=2,
            rectangle split part fill={green!30, red!30},
            rectangle split part align={top, center},
            rounded corners,
            draw,
            minimum height=4cm,
            text width=3cm,
            text centered,
            inner ysep=3mm,
            font = \bfseries] (box) {Weakly solvabable \nodepart{two} Unsolvable};

    \node[above=5mm of box.one south, circle, fill=LimeGreen, font=\bfseries, draw] {Solvable}; 

    \end{tikzpicture}   
\end{document}  

在此处输入图片描述

另一个解决方案是bicolor tcolorbox

\documentclass[border=2pt, tikz, dvipsnames]{standalone}
\usepackage[most]{tcolorbox}
\usetikzlibrary{positioning}
\begin{document}
    \begin{tcolorbox}[
        enhanced,
        bicolor,
        sidebyside,
        halign upper=center,
        halign lower=center,
        fontupper=\bfseries,
        fontlower=\bfseries,
        colframe=black,
        notitle,
        colback=LimeGreen!30,
        colbacklower=OliveGreen!50,
        width=7cm,]
        Weakly Solvable \\
        \begin{tcolorbox}[boxsep=0pt, 
            colback=LimeGreen, 
            colframe=black, 
            halign=center, 
            valign=center, 
            square, circular arc]
                Solvable
        \end{tcolorbox}
        \tcblower
        Unsolvable
   \end{tcolorbox}  
\end{document}  

在此处输入图片描述

相关内容