円の中に円を描く方法

円の中に円を描く方法

TikZ/PGFの使い方を学んでいます。この絵を描きたいです:

ここに画像の説明を入力してください

私が始めたきっかけは次のとおりです。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}  
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}

\begin{document}
    \begin{tikzpicture}
        \node (sun) at (0,0) [circle, fill=yellow, radius=0.3cm]{};
        \node (sunlabel) [above=0.08 of sun]{Sun};
        \node (root) at (0,0) [draw, circle, radius=3cm]{};
    \end{tikzpicture}
\end{document}

問題は、2 番目の円が描画されないことです。何が問題なのかわかりません。この構文は機能しますが、円に名前を付ける方法と、円を色で塗りつぶす方法がわかりません。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}  
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}

\begin{document}
    \begin{tikzpicture}
        \draw (0,0) circle [radius=.3cm, fill=yellow];
        \draw (0,0) circle [radius=2cm];
         \path[
            %rotate=-15.2,
            postaction={
                decoration={
                    text along path,
                    text={%
                        OORT CLOUD
                    },
                    text align=center,
                    reverse path
                },
                decorate
            }
        ]
         (-27:2.2cm) arc (-27:210:2.2cm);
    \end{tikzpicture}
\end{document}

答え1

circle labelPGF は文字列をトークンに分割し、文字からアクセントを分離して奇妙なエラーを引き起こすため、アクセント付き文字を中括弧で囲む必要があります。

動作を強調するためにラベルをフランス語に翻訳しました (私はフランス語を話さないので、間違いが多すぎなかったことを願っています)。

\documentclass[tikz]{standalone}
\usepackage[utf8]{inputenx}
\usetikzlibrary{decorations.text}
\begin{document}
\sffamily
\begin{tikzpicture}[
        white,
        ultra thick,
        planet/.style = {draw,fill,circle,inner sep=#1},
        circle label/.style = {
            postaction={
                decoration={
                    text along path,
                    text = {#1},
                    text align=center,
                    text color=white,
                    reverse path,
                },
            decorate,
        }
        }
    ]
    \filldraw[black] (-7,-7) rectangle (7,8);
    \node at (0,7.5) {\bfseries\Large Voisins les plus proches du soleil};
    \path[circle label={Nuage d'Oort}] (0,-1.2) arc (-90:360-90:1.2);
    \draw[dotted] (0,0) circle (1);
    \foreach \i in {2,4,6} {
        \path[circle label={\i\ Ann{é}e lumi{è}res}] (0,-\i-.2) arc (-90:360-90:\i+.2);
        \draw (0,0) circle (\i);
    }
    \node[yellow,planet=3pt,label={above:Soleil}] at (0,0) {};
    \node[red,planet=3pt,label={[text width=1.5cm,align=right]0:Proxima Centauri déc.\ 1917}] at (44:4.3) {};
    \node[yellow,planet=4pt,label={[text width=2.5cm,align=center]90:Alpha Centauri déc.\ 1917}] at (50:4.3) {};
    \node[red!50!black,planet=2pt,label={[text width=2.5cm,align=center]0:WISE 1049-5319 déc.\ 2013}] at (54:6.3) {};
    \node[red!50!black,planet=2pt] at (57:6.3) {};
    \node[red,planet=3pt,label={[text width=3cm,align=center]95:L'étoile de Bernard déc.\ 1916}] at (125:6) {};
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

答え2

次の構文を使用する場合:

\draw [fill=yellow] (0,0) circle (0.3cm) node (sun) {};

すると、期待通りに動作します。

ここに画像の説明を入力してください

ノート:

  • draw=noneおそらく太陽の周りに境界線は不要だと思うので、太陽にを追加しました。
  • 違いがわかるように、元の行をコメントとして残しました。

コード:

\documentclass[border=2pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}  
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}

\begin{document}
    \begin{tikzpicture}
        %\node (sun) at (0,0) [circle, fill=yellow, radius=0.3cm] {};
        \draw [fill=yellow, draw=none] (0,0) circle (0.3cm)
            node (sun) {};
        \node (sunlabel) [above=0.08 of sun]{Sun};
        %\node (root) at (0,0) [draw=red, circle, radius=3cm] {};
        \draw [draw=red, ultra thick] (0,0) circle (3.0cm)
            node (planet) {};
    \end{tikzpicture}
\end{document}

答え3

PSTricks を使用するとキーストロークが少なくなります。

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(-2,-2)(2,2)
    \pscircle*[linecolor=orange]{5pt}
    \pscircle{2}
\end{pspicture}
\end{document}

ここに画像の説明を入力してください

関連情報