从同一中心点按顺序显示圆圈

从同一中心点按顺序显示圆圈

我想绘制按顺序显示的同心圆。

应用以下代码时,每个圆圈显示时,圆圈似乎从顶部边缘向下移动。

enter image description here enter image description here enter image description here enter image description here enter image description here

如何避免这种情况并使它们从同一中心坐标叠加显示,如本图所示。

enter image description hereenter image description here

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{tkz-fct}
\usetikzlibrary{fadings}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin {center}
\begin{tikzpicture}[scale=.9, transform shape]
  \only<1,5>
{
\node[circle, outer color=yellow!60!green, inner color=white, minimum width=5cm] (radial) at (4,0) {};
\fill[pattern=dots,pattern color = black] (3.6,-.4) -- + +(.8,0) -- ++ (0,.8) -- ++(-.8,0) -- cycle;
}
  \only<4-5>
{
\node[circle, outer color=green!80!purple, inner color=purple, minimum width=4cm] (radial) at (4,0) {};
}
  \only<3-5>
{
\node[circle, outer color=purple, inner color=purple!20!red, minimum width=3cm] (radial) at (4,0) {};
}
  \only<2-5>
{
\node[circle, outer color=purple, inner color=purple!50!black, minimum width=2cm] (radial) at (4,0) {};
}
\end{tikzpicture}
\end {center}
\end{frame}
\end{document}

答案1

一个粗鲁的解决方案是给每张幻灯片添加minimum size最大的一个隐形圆圈:

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{fadings, patterns}

\begin{document}
\begin{frame}[fragile,t]
\frametitle{Circles \dots}
\begin {center}
\begin{tikzpicture}[scale=.9,
circ/.style args = {#1/#2/#3}{circle,outer color=#1, inner color=#2, minimum width=#3,
                              node contents={}},
                    ]
  \only<1,5>
{
\node[circ=yellow!60!green/white/5cm];
\fill[pattern=dots,pattern color = black] (-0.4,-0.4) rectangle + (0.8,0.8);
}
  \only<4-5>
{
\node[circle, minimum size=5cm] {};
\node[circ=green!80!purple/purple/4cm];
}
  \only<3-5>
{
\node[circle, minimum size=5cm] {};
\node[circ=purple/purple!20!red/3cm];
}
  \only<2-5>
{
\node[circle, minimum size=5cm] {};
\node[circ=purple/purple!50!black/2cm];
}
\end{tikzpicture}
\end {center}
\end{frame}
\end{document}

enter image description here enter image description here

笔记:

  • 中的坐标tikzpicure是相对于图片的,而不是幻灯片的。因此,在您的情况下,如果省略坐标的明确符号,则会at (4,0)产生相同的结果。at (0,0)
  • 为了确定幻灯片上绝对位置的坐标,您需要使用remember picture, overlay

    \documentclass{beamer}
    \beamertemplatenavigationsymbolsempty
    \usepackage{tikz}
    \usetikzlibrary{calc, fadings, patterns,
                    overlay-beamer-styles}
    
    \begin{document}
    \begin{frame}[fragile,t]
    \frametitle{Circles \dots}
    \begin{tikzpicture}[remember picture,overlay,
    circ/.style args = {#1/#2/#3}{circle,outer color=#1, inner color=#2, minimum width=#3},
                        ]
      \only<1,5>
    {
    \node[circ=yellow!60!green/white/5cm] (center) at (current page.center) {};
    \fill[pattern=dots,pattern color = black]
        ($(current page.center)+(-0.4,-0.4)$) rectangle + (0.8,0.8);
    }
      \only<4-5>
    {
    \node[circ=green!80!purple/purple/4cm] at (center) {};
    }
      \only<3-5>
    {
    \node[circ=purple/purple!20!red/3cm] at (center) {};;
    }
      \only<2-5>
    {
    \node[circ=purple/purple!50!black/2cm] at (center) {};;
    }
    \end{tikzpicture}
    \end{frame}
    \end{document}
    

enter image description here enter image description here

答案2

图书馆的一个不太粗鲁的解决方案beamer-overlay-styles

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles} %<-added
\usepackage{pgfplots}
\usepackage{tkz-fct}
\usetikzlibrary{fadings}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{Circles with the \texttt{overlay-beamer-styles} library}
\begin {center}
\begin{tikzpicture}[scale=.9, transform shape]
\node[visible on=<{1,5}>,circle, outer color=yellow!60!green, inner color=white, minimum width=5cm] (radial) at (4,0) {};
\fill[visible on=<{1,5}>,pattern=dots,pattern color = black] (3.6,-.4) -- + +(.8,0) -- ++ (0,.8) -- ++(-.8,0) -- cycle;
\node[visible on=<{4-5}>,circle, outer color=green!80!purple, inner color=purple, minimum width=4cm] (radial) at (4,0) {};
\node[visible on=<{3-5}>,circle, outer color=purple, inner color=purple!20!red, minimum width=3cm] (radial) at (4,0) {};
\node[visible on=<{2-5}>,circle, outer color=purple, inner color=purple!50!black, minimum width=2cm] (radial) at (4,0) {};
\end{tikzpicture}
\end {center}
\end{frame}
\end{document}

enter image description here

相关内容