不同线条中的节点之间的阴影区域,节点定义在 \draw 命令中

不同线条中的节点之间的阴影区域,节点定义在 \draw 命令中

这个问题我有一个很好的答案,它为点定义了单独的坐标来遮蔽它们之间的区域。

是否可以在我最初的问题中的 \draw 命令中将这些坐标定义为节点。

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\draw [thick,-latex](0,0) -- (7.6,0) node [black, xshift=.2cm, yshift=0cm] {Q};
\draw [thick,-latex](0,0) -- (0,7) node [black, xshift=0cm, yshift=.2cm] {P};
\path[fill=red!30!white] (2.,4.14) -- (2,1.84) -- (4,3.);
\draw [very thick, blue] (4.,3.) +(-30:2.6cm) -- +(150:4.6cm)  +(30:2.6cm) -- +(-150:4.6cm);
\draw [very thick, red] (.2,3.1) -- +(30:5.cm);
\draw [thick, black, densely dotted] (0,4.14) node [black, xshift=-.28cm, yshift=0cm, align=center] {$P_B$} -- ++(0:2.) node [circle, draw, solid, black, fill=black, scale=0.5]{} -- +(-90:4.14);
\draw [thick, black, densely dotted] (0,3.) node [black, xshift=-.28cm, yshift=0cm, align=center] {$P_1$} -- ++(0:4.) node [circle, draw, solid, black, fill=black, scale=0.5]{} --+(-90:3);
\draw [thick, black, densely dotted] (0,1.84) node [black, xshift=-.28cm, yshift=0cm, align=center] {$P_S$} -- +(0:2.) node [circle, draw, solid, black, fill=black, scale=0.5]{};
\end{tikzpicture}
\end{frame}
\end{document}

答案是:

\coordinate (a) at (2,4.14);
\coordinate (c) at (2,1.86);
\coordinate (d) at (4,3);
\path[fill=red!30!white] (a) -- (c) --(d) --cycle;
\draw [very thick, blue] (4.,3.) +(-30:2.6cm) -- +(150:4.6cm)  +(30:2.6cm) -- +(-150:4.6cm);
\draw [very thick, red] (.2,3.1) -- +(30:5.cm);
\draw [thick, black, densely dotted] (a-|0,0) node [left] {$P_B$} -| (a|-0,0); 
\draw [thick, black, densely dotted] (d-|0,0) node [left] {$P_1$} -| (d|-0,0); 
\draw [thick, black, densely dotted] (c-|0,0) node [left] {$P_S$} -| (c|-0,0); 

在此处输入图片描述

答案1

我猜你想用项目符号的中心来定义阴影区域的角。为此,请为项目符号节点命名,并使用 引用它们的中心.center

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\draw [thick,-latex](0,0) -- (7.6,0) node [black, xshift=.2cm, yshift=0cm] {Q};
\draw [thick,-latex](0,0) -- (0,7) node [black, xshift=0cm, yshift=.2cm] {P};
\draw [very thick, blue] (4.,3.) +(-30:2.6cm) -- +(150:4.6cm)  +(30:2.6cm) -- +(-150:4.6cm);
\draw [very thick, red] (.2,3.1) -- +(30:5.cm);
\draw [thick, black, densely dotted] (0,4.14) node [black, xshift=-.28cm,
yshift=0cm, align=center] {$P_B$} -- ++(0:2.) node [circle, draw, solid, black,
fill=black, scale=0.5](x1){}  -- +(-90:4.14);
\draw [thick, black, densely dotted] (0,3.) node [black, xshift=-.28cm,
yshift=0cm, align=center] {$P_1$} -- ++(0:4.) node [circle, draw, solid, black,
fill=black, scale=0.5](x2){}  --+(-90:3);
\draw [thick, black, densely dotted] (0,1.84) node [black, xshift=-.28cm,
yshift=0cm, align=center] {$P_S$} -- +(0:2.) node [circle, draw, solid, black,
fill=black, scale=0.5](x3){};
\begin{scope}[on background layer]
\path[fill=red!30!white] (x1.center) -- (x2.center) -- (x3.center)  -- cycle;
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

答案2

好吧,你已经收到了答案,这正是你想要的:-),所以这个答案是为了练习......

  • 当我测试您提供的代码时,我得到了相同的结果,所以我想知道,您的问题是什么?
  • 你的代码没有必要那么复杂。我建议你以类似于编写 Latex 文档的方式绘制图像:首先定义样式(通过加载包),然后编写内容,即在绘制图像时首先定义元素的通用样式,然后编写图像代码:

    \documentclass{beamer}
    \beamertemplatenavigationsymbolsempty
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.16}
    
    \begin{document}
    \begin{frame}[fragile,t]
    \frametitle{}
        \begin{tikzpicture}[
            scale = .9, thick,
                > = latex,
       dot/.style = {circle, fill, inner sep=2pt,
                     node contents={}},
                            ]
    \draw [->] (0,0) -- (7,0) node [black, right] {Q};
    \draw [->] (0,0) -- (0,7) node [black, above] {P};
    %
    \path [fill=red!30!white] (2.,4.14) -- (2,1.84) -- (4,3.);
    %
    \draw [very thick, blue]    (4,3)+(-30:2.6) -- +(150:4.6cm)+(30:2.6) -- +(-150:4.6cm);
    \draw [very thick, red]     (.2,3.1)        -- +(30:5.cm);
    
    \draw [densely dotted] (0,4.14) node [left] {$P_B$} -| (2,0)  node[dot, pos=0.5];
    \draw [densely dotted] (0,3.00) node [left] {$P_1$} -| (4,0)  node[dot, pos=0.5];
    \draw [densely dotted] (0,1.84) node [left] {$P_S$} -| (2,0)  node[dot, pos=0.5];
        \end{tikzpicture}
    \end{frame}
    \end{document}
    

在此处输入图片描述

相关内容