tikz 노드의 배치 및 불투명도

tikz 노드의 배치 및 불투명도

저는 국방 프레젠테이션을 위한 일종의 로드맵으로 사용하고 싶은 다음과 같은 MWE를 얻었습니다. 기본적으로 모두 작동하고 좋아 보이지만 두 가지가 있는데 어떻게 수정해야 할지 모르겠습니다. 첫 번째는 노드가 정확히 서로 겹치도록 표시하는 방법입니다. 예를 들어 논문 오른쪽의 시작점은 거기에서 출발하는 세 경로 모두에서 동일합니다. 두 번째 문제는 각 노드 내부의 원을 선 및 채우기와 동일한 불투명도로 만드는 방법에 관한 것입니다.

\documentclass{standalone}

\usepackage[dvipsnames]{xcolor}

\usepackage{tikz}
\usepackage{lmodern}

\usepackage{pgfplots}

\usetikzlibrary{ arrows
                , positioning
                , calc
                , arrows.meta
                , shapes
                , snakes}
\colorlet{Navyblue}{NavyBlue}
\tikzstyle{project} = [
            align=left
        %, fill=NavyBlue
        , opacity=0.2
        , text opacity=1]

\newcommand{\myopacity}{1}

\begin{document}

\begin{tikzpicture}[baseline=(current bounding box.center), font=\sffamily, node distance=2cm]
\draw
  node[project,anchor=east](P) {\textbf{Dissertation}}

  node[project
        ,right= 2in of P.east
        , anchor=east
        , text opacity=0.4](P23) {}

   node[project
            , above= of P23.west
            , anchor = west
            ](P1) {\textbf{Project I:}}

   node[project
        , right = 1in of P23
        , text opacity=0.4](P2) {Project II: }
   node[project
        , below= 0.5in of P2.west
        , anchor=west
        , text opacity=0.4](P3) {Project III: }
    node[project
        , below= of P23.west
        , anchor=west
        , text opacity=0.4](P4) {Project IV:};                                                              
   % Define different colors
  \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , Gray
        , opacity = 0.4] (P.east) -- (P23.west);
  \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , darkgray
        , opacity = 0.4] (P23.east) -- (P2.west);
  \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , darkgray
        , opacity = 0.4
        ] (P23.east) -- (P3.west);
  \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
            , line width=2pt
            , Gray
            , opacity = \myopacity] (P.east) -- (P1.west);
  \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , RoyalBlue
        , opacity = 0.4] (P.east) -- (P4.west);
    \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
            , line width=2pt
            , Gray
            , opacity = \myopacity] (P.east) -- (P1.west);

\end{tikzpicture}

\end{document}

결과 그래픽의 스크린샷 이는 첫 번째 의견에서 제안된 변경 사항의 결과입니다. 결과

답변1

노드에 텍스트를 배치하는 대신:node[project,anchor=east](P) {\textbf{Dissertation}}

나는 그것들을 라벨로 배치합니다. 레이블은 노드이며 노드와 동일한 옵션을 가지며 동일한 방식으로 수정할 수 있습니다.node[project,anchor=east,label={left:\textbf{Dissertation}}](P) {}

이렇게 하면 원형 노드를 그릴 수 있습니다.

\tikzset{project/.style={ align=left 
                          %, fill=NavyBlue
                          , opacity=0.2 
                          , text opacity=1 
                          ,draw %draw a circle node 
                          ,circle}
                         }

이는 노드 간의 선 그리기 코드를 단순화합니다. 후자는 빈 노드를 연결하며 다음과 같이 위치 P.east를 지정 P23.west하거나 끝을 원으로 그릴 필요가 없습니다 .{Circle[length=8pt]}-{Circle[length=8pt]}

   \draw[{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , Gray
        , opacity = 0.4] (P.east) -- (P23.west);

코드는 다음과 같습니다:

 \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , Gray
        , opacity = 0.4] (P) edge (P23);

쓸모 없게 된 모든 코드 줄을 삭제하지 않고 댓글을 달았습니다.

새 노드를 만들었습니다 (P23').

  node[project
        ,right= 2in of P
        %, anchor=east
        , text opacity=0.4](P23) {}
  node[project
        ,right= 10pt of P23
        %, anchor=east
        , text opacity=0.4](P23') {}

스크린샷

\documentclass{standalone}

\usepackage[dvipsnames]{xcolor}

\usepackage{tikz}
\usepackage{lmodern}

\usepackage{pgfplots}

\usetikzlibrary{ %arrows
                , positioning
                , calc
                , arrows.meta
                , shapes
                , snakes}
\colorlet{Navyblue}{NavyBlue}
\tikzset{project/.style={
            align=left
        %, fill=NavyBlue
        , opacity=0.2
        , text opacity=1
        ,draw
        ,circle}}

\newcommand{\myopacity}{1}

\begin{document}

\begin{tikzpicture}[%baseline=(current bounding box.center),
 font=\sffamily,
  node distance=2cm]
\draw
  node[project,anchor=east,label={left:\textbf{Dissertation}}](P) {}

  node[project
        ,right= 2in of P
        %, anchor=east
        , text opacity=0.4](P23) {}
  node[project
        ,right= 10pt of P23
        %, anchor=east
        , text opacity=0.4](P23') {}
   node[project
            , above= of P23
            %, anchor = west
            , label= right:\textbf{Project I:}
            ](P1) {}

   node[project
        , right = 1in of P23
        , text opacity=0.4
        ,label=right:Project II: ](P2) {}
   node[project
        , below= 0.5in of P2
       % , anchor=west
        , text opacity=0.4,label=right:Project III: ](P3) {}
    node[project
        , below= of P23
        %, anchor=west
        , text opacity=0.4
        ,label=below:Project IV:](P4) {};                                                              
   % Define different colors
  \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , Gray
        , opacity = 0.4] (P) edge (P23);
  \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , darkgray
        , opacity = 0.4] (P23') -- (P2);
  \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , darkgray
        , opacity = 0.4
        ] (P23') -- (P3);
  \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
            , line width=2pt
            , Gray
            , opacity = \myopacity] (P) -- (P1);
  \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
        , line width=2pt
        , RoyalBlue
        , opacity = 0.4] (P) -- (P4);
    \draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
            , line width=2pt
            , Gray
            , opacity = \myopacity] (P) -- (P1);

\end{tikzpicture}

\end{document}

관련 정보