
Ich habe das folgende MWE, das ich als eine Art Fahrplan für die Verteidigungspräsentation verwenden möchte. Im Grunde funktioniert alles und sieht gut aus, aber es gibt zwei Dinge, bei denen ich nicht weiß, wie ich sie beheben soll. Das erste Problem ist, wie man die Knoten genau übereinander erscheinen lässt, sodass beispielsweise der Startpunkt rechts von Dissertation für alle drei von dort ausgehenden Pfade derselbe ist. Das zweite Problem ist, wie man den Kreis innerhalb jedes Knotens so deckend macht wie die Linie und die Füllung.
\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}
Dies ist das Ergebnis der im ersten Kommentar vorgeschlagenen Änderungen:
Antwort1
Anstatt die Texte in den Knoten zu platzieren:node[project,anchor=east](P) {\textbf{Dissertation}}
Ich platziere sie als Beschriftung. Beschriftungen sind Knoten, sie haben die gleichen Optionen wie Knoten und können auf die gleiche Weise geändert werden:node[project,anchor=east,label={left:\textbf{Dissertation}}](P) {}
Dadurch können Sie kreisförmige Knoten zeichnen:
\tikzset{project/.style={ align=left
%, fill=NavyBlue
, opacity=0.2
, text opacity=1
,draw %draw a circle node
,circle}
}
Dies vereinfacht den Code zum Zeichnen von Linien zwischen Knoten. Letztere verbinden leere Knoten und es ist nicht erforderlich, die P.east
Position anzugeben P23.west
oder ihre Enden in einem Kreis zu zeichnen, wie:{Circle[length=8pt]}-{Circle[length=8pt]}
\draw[{Circle[length=8pt]}-{Circle[length=8pt]}
, line width=2pt
, Gray
, opacity = 0.4] (P.east) -- (P23.west);
Der Code wird:
\draw[%{Circle[length=8pt]}-{Circle[length=8pt]}
, line width=2pt
, Gray
, opacity = 0.4] (P) edge (P23);
Ich habe alle Codezeilen kommentiert, die unbrauchbar geworden sind, ohne sie zu löschen.
Ich habe einen neuen Knoten erstellt (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}