Graphik in Latex

Tabellen und Grafiken erstellen und anordnen


ap.1900.data
Forum-Anfänger
Forum-Anfänger
Beiträge: 13
Registriert: So 26. Mai 2024, 10:29

Graphik in Latex

Beitrag von ap.1900.data »

Hallo zusammen,
ich versuche folgende Graphik nachzubasteln in Latex:

Bild



Ich habe folgenden Code dazu gebastelt:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}

\begin{tikzpicture}[
    node distance=1.5cm and 2.5cm,
    every node/.style={draw, rectangle, align=center, rounded corners},
    pre/.style={->,>=stealth',thick,draw=black!50},
    post/.style={->,>=stealth',thick,draw=black!50}
]

\node (research) [text width=4cm, fill=white] {Research design};
\node (traditional) [below left=of research, text width=3cm, fill=blue!20] {Traditional class};
\node (flipped) [below right=of research, text width=3cm, fill=blue!20] {Flipped class};
\node (pretest) [below=of research, text width=5cm, fill=white] {Pre-test algebra proficiency\\ Pre-test self-efficacy};
\node (training) [right=of flipped, xshift=-1cm, text width=3cm, fill=white] {Training sessions on the flipped approach};
\node (traditional_lessons) [below=of traditional, text width=3cm, fill=blue!20] {Traditional lessons};
\node (flipped_lessons) [below=of flipped, text width=3cm, fill=blue!20] {Flipped lessons};
\node (survey) [right=of flipped_lessons, xshift=-1cm, text width=3cm, fill=white] {Post-treatment survey};
\node (posttest) [below=of pretest, text width=5cm, fill=white] {Post-test algebra proficiency\\ Post-test self-efficacy};
\node (interview) [below=of posttest, text width=4cm, fill=white] {Teacher interview};

% Arrows
\draw[pre] (research) -- (traditional);
\draw[pre] (research) -- (flipped);
\draw[pre] (traditional) -- (pretest);
\draw[pre] (flipped) -- (pretest);
\draw[pre] (flipped) -- (training);
\draw[pre] (training) -- ++(0, -2) -| (pretest);
\draw[pre] (pretest) -- (traditional_lessons);
\draw[pre] (pretest) -- (flipped_lessons);
\draw[post] (flipped_lessons) -- (survey);
\draw[pre] (traditional_lessons) -- (posttest);
\draw[pre] (flipped_lessons) -- (posttest);
\draw[pre] (posttest) -- (interview);

% Text Annotations
\node at ($(pretest) + (-4, 0)$) {Weeks 1 + 2};
\node at ($(traditional_lessons) + (-4, 0)$) {Weeks 3 to 8};
\node at ($(posttest) + (4, 0)$) {Week 9};

\end{tikzpicture}

\end{document}
Ich würde mich über eure Hilfe sehr freuen, sodass ich näher an die Zielgraphik komme.

VG & Danke
AP

ap.1900.data
Forum-Anfänger
Forum-Anfänger
Beiträge: 13
Registriert: So 26. Mai 2024, 10:29

Re: Graphik in Latex

Beitrag von ap.1900.data »

Liebes Forum,
Ich stehe leider noch immer bei der im Anfangsbeitrag erwähnten Graphik auf dem Schlauch und waere über eure Hilfe sehr dankbar.
Lg
Ap

Stammgast

Re: Graphik in Latex

Beitrag von Stammgast »

Das Beispiel ist so nicht übersetzbar. Es fehlen mindestens die Bibliotheken (Libraries) 'arrows.meta', 'calc' und 'positioning'. Darüber hinaus gibt es die Form 'stealth'' für Pfeile nicht. Verwende 'stealth' oder eine andere in der Anleitung beschriebene Form.

ap.1900.data
Forum-Anfänger
Forum-Anfänger
Beiträge: 13
Registriert: So 26. Mai 2024, 10:29

Re: Graphik in Latex

Beitrag von ap.1900.data »

Hallo,
Vielen Dank für deine Antwort. Mein Verbesserungsvorschlag:
 \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, calc, arrows.meta} % Required TikZ libraries

\begin{document}

\begin{tikzpicture}[
    node distance=1.5cm and 2.5cm,
    every node/.style={draw, rectangle, align=center, rounded corners, fill=blue!20, text width=3cm, minimum height=1.5cm},
    pre/.style={->,>=stealth, thick, draw=black!50},
    post/.style={->,>=stealth, thick, draw=black!50}
]

\node (research) {Research design};
\node (traditional) [below left=of research] {Traditional class};
\node (flipped) [below right=of research] {Flipped class};
\node (pretest) [below=of research, text width=5cm, align=center, fill=white] {Pre-test algebra proficiency\\ Pre-test self-efficacy};
\node (training) [right=of flipped, xshift=-1cm, text width=3cm, align=center, fill=white] {Training sessions on flipped approach};
\node (traditional_lessons) [below=of traditional] {Traditional lessons};
\node (flipped_lessons) [below=of flipped] {Flipped lessons};
\node (survey) [right=of flipped_lessons, xshift=-1cm, text width=3cm, align=center, fill=white] {Post-treatment survey};
\node (posttest) [below=of pretest, text width=5cm, align=center, fill=white] {Post-test algebra proficiency\\ Post-test self-efficacy};
\node (interview) [below=of posttest, text width=4cm, align=center, fill=white] {Teacher interview};

% Arrows
\draw[pre] (research) -- (traditional);
\draw[pre] (research) -- (flipped);
\draw[pre] (traditional) -- (pretest);
\draw[pre] (flipped) -- (pretest);
\draw[pre] (flipped) -- (training);
\draw[pre] (training) |- (pretest);
\draw[pre] (pretest) -- (traditional_lessons);
\draw[pre] (pretest) -- (flipped_lessons);
\draw[post] (flipped_lessons) -- (survey);
\draw[pre] (traditional_lessons) -- (posttest);
\draw[pre] (flipped_lessons) -- (posttest);
\draw[pre] (posttest) -- (interview);

% Text Annotations
\node at ($(pretest) + (-4, 0)$) {Weeks 1 + 2};
\node at ($(traditional_lessons) + (-4, 0)$) {Weeks 3 to 8};
\node at ($(posttest) + (4, 0)$) {Week 9};

\end{tikzpicture}

\end{document}
 
So ganz passt es noch nicht.

Lg
AP

rais
Forum-Guru
Forum-Guru
Beiträge: 413
Registriert: Di 21. Sep 2010, 00:37

Re: Graphik in Latex

Beitrag von rais »

Wenn Du Dir die Mühe gemacht hättest, den Code mal auf die ersten beiden Nodes zu reduzieren ((research) und (traditional)), wäre Dir vllt aufgefallen, daß bei
    node distance=1.5cm and 2.5cm,
und
\node (research) {Research design};
\node (traditional) [below left=of research] {Traditional class};
die rechte, obere Ecke von (traditional) 1,5 cm unterhalb und 2,5 cm links von der unteren, linken Ecke von (research) gesetzt wird und bereits sehr von Deinem Bild abweicht. Da dann noch andere Nodes setzen zu wollen ist kontraproduktiv (und hat wohl schon den einen oder anderen Helfer hier abgeschreckt).
Mein Vorschlag:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, positioning, decorations.pathreplacing}
\newlength\braceoffset
\setlength\braceoffset{2.5mm}
\newif\ifshowinfo
\showinfotrue
\begin{document}

\begin{tikzpicture}[>=stealth,
    node distance=1cm and 5mm,  %1.5cm and 2.5cm,
    every node/.style={draw, rectangle, text width=3cm, align=center, rounded corners, minimum height=1cm},
    week/.style={thin, midway, text width=2cm},
    wide/.style={minimum width=7cm, text width=5cm},
    class/.style={fill=blue!20},
    my brace/.style={semithick, decorate, decoration={brace, amplitude=3mm}},
    my line/.style={black!50, thick},
    info/.style={minimum height=1ex, text width={}, draw=none, blue!75!black},
    pre/.style={my line, ->},
    rev/.style={my line, <-}
]

\node (research) [text width=4cm] {Research design};
\coordinate [below=2cm of research] (hrd); %Stützpunkt
\coordinate [below=7.5mm of research] (hrdl); %Stützpunkt für Linien
\node (traditional) [left=of hrd, class] {Traditional class};
\node (flipped) [right=of hrd, class] {Flipped class};
\node (pretest) [below=3.5cm of hrd, wide] {Pre-test algebra proficiency\\ Pre-test self-efficacy};
%\coordinate [below=1.5cm of pretest] (hpt); %Stützpunkt
\node (training) [below=of flipped] {\footnotesize Training sessions on the flipped approach};
\node (flipped_lessons) [below right=of pretest.south, class] {Flipped lessons};

% Arrows
\draw[my line] (research) -- (hrdl);
\draw[pre, rounded corners=3mm] (hrdl) -| (traditional);
\draw[pre, rounded corners=3mm] (hrdl) -| (flipped);
\draw[pre] (traditional)
  -- ($(pretest.north west)!(traditional)!(pretest.north)$);
% siehe `texdoc pgfmanual', Abschnitt ``The Syntax of Projection Modifiers''
\draw[pre] (flipped) -- (training);
\draw[pre] (training)
  -- ($(pretest.north)!(training)!(pretest.north east)$);
\draw[rev] (flipped_lessons)
  -- ($(pretest.south)!(flipped_lessons)!(pretest.south east)$);
% Braces + Annotations:
\coordinate[above=\braceoffset of training.north east, xshift=\braceoffset] (bbrc);
\coordinate[below=\braceoffset of pretest.south east] (ebrca);
\coordinate[right=1.5cm of ebrca] (ebrcb);
\draw[my brace] (bbrc) -- ($(ebrca)!(bbrc)!(ebrcb)$)
  node[week, right=5mm]{Weeks 1 + 2};% und mittig zur Klammer den Text nach rechts
% nur zur Demo:
\ifshowinfo
  \draw[blue!30, ->] (training.north east) |- (bbrc) node[info, near start, left]{$\delta$ (above)}
    node[info, near end, above]{$\delta$ (xshift)};
  \draw[blue!30, ->] (pretest.south east) -- (ebrca)
    node[info, midway, left]{$\delta$ (below)};
  \foreach \i in {hrd,hrdl,bbrc,ebrca,ebrcb}{%
    \draw[red!50] (\i) circle[radius=0.25mm];
    \draw[red!20] (\i) -- +(330:1) node[info, below, red!75!black]{(\i)};
  }
  \draw[red!20] ($(pretest.north west)!(traditional)!(pretest.north)$) -- +(310:5)
  node[info, below, red!75!black]{(\$(pretest.north west)!(traditional)!(pretest.north)\$)};
  \draw[blue!30, dashed]  (ebrca) -- (ebrcb) node[info, right]{gedachte Linie};
  \draw[blue!30, <->] (pretest.south) -- +(0,-1) node[info, midway, left]{node distance};
  \draw[blue!30, <->] (flipped_lessons.north west) -- +(-0.5,0) node[info, midway, below]{node distance (and)};
\fi
\end{tikzpicture}
\end{document}
(meine Hilfslinien/Koordinaten kannst Du durch Auskommentieren von \showinfotrue unterdrücken)

VG
Rainer
One of the joys of travel is visiting new towns and meeting new people---G.Khan (Robert Asprin, Another Fine Myth)

Antworten