对曲线所围区域进行着色

对曲线所围区域进行着色

当我想为曲线所围成的区域着色时,我遇到了一个问题\sigma^{(0)}, \sigma^{(1)}, \sigma^{(0)}。我使用命令, 但它只为由 3 个顶点、、\draw[fill=red!30, opacity=.5] (h2)--(h3)--(h4)--cycle; 形成的三角形着色。如下图所示:v_0v_1v_2

在此处输入图片描述

这是我的代码

\documentclass[12pt]{article}

\usepackage{epsfig,psfrag}

\usepackage{amsmath,amsxtra,amssymb,latexsym,amscd,amsthm}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{graphicx}
\setlength{\textwidth}{6.2in}
\setlength{\oddsidemargin}{0.3in}
\setlength{\evensidemargin}{0in}
\setlength{\textheight}{8.7in}
\setlength{\voffset}{-.7in}
\setlength{\headsep}{26pt}
\setlength{\parindent}{10pt}

\usepackage{epic}
\usepackage{curves}

\usepackage{tikz, tikz-3dplot, pgfplots}
\usepackage{tkz-graph}
\usetikzlibrary{calc,arrows.meta}
\usetikzlibrary{shapes.geometric,calc}
\usetikzlibrary[positioning,patterns]
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}  
\usetikzlibrary{arrows,calc,shapes,decorations.pathreplacing}
\usepackage{tikz-cd}


\usepackage{young}
\usepackage[vcentermath]{youngtab}

\begin{document}
\begin{tikzpicture}
  [decoration={markings,mark=at position 0.5 with {\arrow{>}}},
   witharrow/.style={postaction={decorate}},
   shorten <>/.style={shorten <=#1,shorten >=#1},
   dot/.style={radius=2pt}
  ]


  % ellipse
  \begin{scope}
    \fill 
          (-2,0) coordinate (h1) circle[dot] node[left](k1){$q$}
          (2,0) coordinate (h2) circle[dot] node[below](k2){$v_0$}
          (4,2) coordinate (h3) circle[dot] node[above](k3){$v_2$}
          (5,-2) coordinate (h4) circle[dot] node[below](p3){$v_1$}
          (0,0) coordinate (a3)  node[left](p3){}

          (5,0.5) coordinate (b3)  node[right]{}
          (1,-0.5) coordinate (c3) node[right]{};


     \draw[bend right=20,witharrow]  (h1) to node [anchor=south]{$\alpha(v_0)$} (h2);      
      \draw[bend left=30,witharrow]  (h1) to node [anchor=south]{$\alpha(v_2)$} (h3);       
       \draw[bend right=30,witharrow]  (h1) to node [anchor=north]{$\alpha(v_1)$} (h4);    
          \draw[bend right=30,witharrow]  (h2) to node [anchor=south]{$\sigma^{(1)}$} (h3); 
           \draw[bend left=20,witharrow]  (h2) to node [anchor=north]{$\sigma^{(2)}$} (h4); 
          \draw[bend left=25,witharrow]  (h3) to node [anchor=west]{$\sigma^{(0)}$} (h4); 
\draw ($0.5*(a3)+0.5*(b3)$) circle[x radius=6,y radius=4];
    \node at ($(a3)+(6,2.5)$) (X3) {$X$};      
    \draw[fill=red!30, opacity=.5] (h2)--(h3)--(h4)--cycle;    
\end{scope}          
\end{tikzpicture}
\end{document}

我该如何解决这个问题?有人能给我一些建议吗?

答案1

您可以使用:

        \path [fill=red!30, opacity=.5] (h2) to [ bend right=30] (h3) to [ bend left=25] (h4) to [ bend right=20] (h2);   

梅威瑟:

\documentclass[12pt]{article}

\usepackage{epsfig,psfrag}

\usepackage{amsmath,amsxtra,amssymb,latexsym,amscd,amsthm}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{graphicx}
\setlength{\textwidth}{6.2in}
\setlength{\oddsidemargin}{0.3in}
\setlength{\evensidemargin}{0in}
\setlength{\textheight}{8.7in}
\setlength{\voffset}{-.7in}
\setlength{\headsep}{26pt}
\setlength{\parindent}{10pt}

\usepackage{epic}
\usepackage{curves}

\usepackage{tikz, tikz-3dplot, pgfplots}
\usepackage{tkz-graph}
\usetikzlibrary{calc,arrows.meta}
\usetikzlibrary{shapes.geometric,calc}
\usetikzlibrary[positioning,patterns]
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}  
\usetikzlibrary{arrows,calc,shapes,decorations.pathreplacing}
\usepackage{tikz-cd}


\usepackage{young}
\usepackage[vcentermath]{youngtab}

\begin{document}
\begin{tikzpicture}
  [decoration={markings,mark=at position 0.5 with {\arrow{>}}},
   witharrow/.style={postaction={decorate}},
   shorten <>/.style={shorten <=#1,shorten >=#1},
   dot/.style={radius=2pt}
  ]

  \begin{scope}
    \fill 
          (2,0) coordinate (h2) circle[dot] node[below](k2){$v_0$}
          (4,2) coordinate (h3) circle[dot] node[above](k3){$v_2$}
          (5,-2) coordinate (h4) circle[dot] node[below](p3){$v_1$};

          \draw[bend right=30,witharrow]  (h2) to node [anchor=south]{$\sigma^{(1)}$} (h3); 
           \draw[bend left=20,witharrow]  (h2) to node [anchor=north]{$\sigma^{(2)}$} (h4); 
          \draw[bend left=25,witharrow]  (h3) to node [anchor=west]{$\sigma^{(0)}$} (h4); 


 \path [fill=red!30, opacity=.5] (h2) to [ bend right=30] (h3) to [ bend left=25] (h4) to [ bend right=20] (h2); 
\end{scope}          
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

Bobyandbob 已经向您展示了如何填充该区域,因此这在某种程度上更像是一种评论,并在您的代码中添加了一些额外的注释。

  • 要更改页边距等,通常应使用geometry包,而不是像您那样手动设置长度。也就是说,使用类似

    \usepackage[
      textwidth=6.2in,
      textheight=8.7in,
      headsep=26pt
      ]{geometry}
    
  • epsfig包已被 取代graphicx,因此无需使用它。(现在它实际上只是一个包装器graphicx。)如果您需要包含.eps文件,请\includegraphics{filename}照常使用 。

  • 您两次加载了多个 TikZ 库,这是不必要的。而且在一个地方您使用了\usetikzlibrary[..]\usetikzlibrary{..}它显然仍然有效,但后者是记录在案的方法)。
  • 就最小示例而言,下面的代码更加简单,正如 bobyandbob 提到的,你的序言中有很多不相关的内容。
  • 我建议先画线,再填充,然后再画点。

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,calc}
\begin{document}
\begin{tikzpicture}
  [decoration={markings,mark=at position 0.5 with {\arrow{>}}},
   witharrow/.style={postaction={decorate}},
   shorten <>/.style={shorten <=#1,shorten >=#1},
   dot/.style={radius=2pt}
  ]

\fill 
          (-2,0)   coordinate (h1) node[left](k1){$q$}
          (2,0)    coordinate (h2) node[below](k2){$v_0$}
          (4,2)    coordinate (h3) node[above](k3){$v_2$}
          (5,-2)   coordinate (h4) node[below](p3){$v_1$}
          (0,0)    coordinate (a3)
          (5,0.5)  coordinate (b3)
          (1,-0.5) coordinate (c3);


\fill[red!30,opacity=.5]
 (h2) to[bend right=30] (h3)
      to[bend left=25]  (h4) 
      to[bend right=20] (h2);

\draw[bend right=20,witharrow]  (h1) to node [anchor=south]{$\alpha(v_0)$} (h2);      
\draw[bend left=30,witharrow]   (h1) to node [anchor=south]{$\alpha(v_2)$} (h3);       
\draw[bend right=30,witharrow]  (h1) to node [anchor=north]{$\alpha(v_1)$} (h4);    
\draw[bend right=30,witharrow]  (h2) to node [anchor=south]{$\sigma^{(1)}$} (h3); 
\draw[bend left=20,witharrow]   (h2) to node [anchor=north]{$\sigma^{(2)}$} (h4); 
\draw[bend left=25,witharrow]   (h3) to node [anchor=west]{$\sigma^{(0)}$} (h4); 
\draw ($0.5*(a3)+0.5*(b3)$) circle[x radius=6,y radius=4];
\node at ($(a3)+(6,2.5)$) (X3) {$X$};      

\foreach \x in {h1,h2,h3,h4}
   \fill (\x) circle[dot];
\end{tikzpicture}
\end{document}

相关内容