不同线路中节点之间的阴影区域

不同线路中节点之间的阴影区域

使用以下代码,我使用单独的 \draw 或 \path 命令对区域进行阴影处理。有没有办法直接从绘制的虚线命令中对不同线条中的节点之间的这些区域进行阴影处理;以避免重新定义它们的坐标。

\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};

\draw [ultra thin, red!30!white, fill=red!30!white] (2.,4.14) -- ++(-90:1.14) -- +(0:2.);
\path[fill=red] (2.,3.) -- ++(-90:1.14) -- +(30:2.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]{};

\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]{} --+(-90:1.84) ;

\draw [thick, black, densely dotted] (2.,4.14) -- +(-90:2.23) node [pos=.5,circle, draw, solid, black, fill=black, scale=0.5]{};
\end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

答案1

这就是coordinate节点的作用。请阅读“给卡尔学生们的一张照”“欧几里得琥珀版的《几何原本》”,它们易于阅读和理解。你将用它们解决所有这类问题TikZ

\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};

\coordinate (a) at (2,4.14);
\coordinate (b) at (2,3);
\coordinate (c) at (2,1.86);
\coordinate (d) at (4,3);

\draw [ultra thin, red!30!white, fill=red!30!white] (a) -- (b) -- (d) -- cycle;

\path[fill=red] (c) -- (b) --(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); 

\foreach \i in {a,b,c,d}
    \path[fill=black] (\i) circle(3pt); 
\end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

相关内容