凸集图片

凸集图片

我正在尝试这样做:

在此处输入图片描述

这是我的尝试:

\documentclass[12pt,a4paper]{book}

\usepackage{tikz}

\usetikzlibrary{calc, shadings} 

\usetikzlibrary{positioning,arrows.meta}

\begin{document}

\begin{tikzpicture}

\pgfmathsetmacro{\myslope}{atan2(2,-4.5)}

\draw[fill=gray!30] (M) to[out=\myslope,in=0] ++ (-2,0.5) to[out=180,in=90] ++ (-1,-0.5)

 to[out=-90,in=90] ++ (2,-2) to[out=-90,in=90] ++ (-3,-1)

 to[out=-90,in=180] ++(4,-1) to[out=0,in=\myslope+180] cycle;

\end{tikzpicture}

\end{document}

你能帮助我吗?

答案1

在此处输入图片描述

\documentclass[12pt]{book}
\usepackage{caption, subcaption}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                bbox}

\begin{document}
    \begin{figure}[ht]
    \centering
    \captionsetup[subfigure]{labelformat=simple}
    \renewcommand\thesubfigure{}
\subfloat[][Convex set]%
{
    \begin{tikzpicture}[bezier bounding box]
\draw[fill=gray!30] 
    (0,0) .. controls +(0,3) and + (0,2) .. (5,1)
          .. controls +(0,-3) and + (0,-2) .. 
          cycle;
\draw[Circle-Circle]  
    (1,-0.2)    node[above] {$x_1$} -- ++ (3,1)
                node[above] {$x_2$};
\end{tikzpicture}
}
\hfil
\subfloat[][Non-convex set]%
{
    \begin{tikzpicture}[bezier bounding box]
\draw[fill=gray!30]
    (0,0) .. controls +(0,4) and + (-1,0) .. (3,1)
          .. controls +(1,0) and + ( 0,2) .. (5,0)
          .. controls +(0,-2) and + (1,0) .. (2,0)
          .. controls +(-1,0) and + (0,-2) ..
          cycle;
\draw[Circle-Circle]
    (1,-0.2)    node[above] {$x_1$} -- ++ (3,0)
                node[above] {$x_2$};
\end{tikzpicture}
}
    \end{figure}
\end{document}

Z 库bbox可在加拿大运输安全局

相关内容