pgfplots/tikz: Anordnung mehrerer Diagramme im 2x2-Raster mit teilweisem Verzicht auf tick labels Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


Benni1050
Forum-Newbie
Forum-Newbie
Beiträge: 6
Registriert: Mi 31. Jan 2018, 13:56

pgfplots/tikz: Anordnung mehrerer Diagramme im 2x2-Raster mit teilweisem Verzicht auf tick labels

Beitrag von Benni1050 »

Hallo zusammen,

gerne möchte ich innerhalb einer \minipage vier mittels pgfplots\tikz erstellte Diagramme in einem 2x2-Raster anordnen. Dabei kann bei den oberen beiden Diagrammen auf die xtick labels, bei den rechten beiden Diagrammen auf die ytick labels verzichtet werden. Da die Diagramme damit aber unterschiedliche Abmessungen haben, sind diese nicht mehr horizontal und vertikal zueinander ausgerichtet.

Hat jemand von Euch eine Lösung dafür?

\documentclass{scrreprt}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}
	\begin{center}
	\begin{minipage}{\textwidth}
  	\centering
		\begin{tikzpicture}
			\begin{semilogyaxis}[scale=0.9,log ticks with fixed point, xmin=0,xmajorticks=false,xmajorgrids,xmax=100,ymajorgrids,yminorgrids,ymax=100,ymin=0.01]
			\end{semilogyaxis}
		\end{tikzpicture}
		\begin{tikzpicture}
			\begin{semilogyaxis}[scale=0.9,log ticks with fixed point,xmin=0,xmajorticks=false,xmajorgrids,xmax=100,ymajorticks=false,ymajorgrids,yminorgrids,ymax=100,ymin=0.01]
			\end{semilogyaxis}
		\end{tikzpicture}
		\begin{tikzpicture}
			\begin{semilogyaxis}[scale=0.9,log ticks with fixed point,xmin=0,xmajorgrids,xmax=100,ymajorgrids,yminorgrids,ymax=100,ymin=0.01]
			\end{semilogyaxis}
		\end{tikzpicture}
		\begin{tikzpicture}
			\begin{semilogyaxis}[scale=0.9,log ticks with fixed point,xmin=0,xmajorgrids,xmax=100,ymajorticks=false,ymajorgrids,yminorgrids,ymax=100,ymin=0.01]
			\end{semilogyaxis}
		\end{tikzpicture}
	\end{minipage}
	\end{center}
\end{document}

Danke und viele Grüße

Benni


Bartman
Forum-Meister
Forum-Meister
Beiträge: 2456
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Re: pgfplots/tikz: Anordnung mehrerer Diagramme im 2x2-Raster mit teilweisem Verzicht auf tick labels

Beitrag von Bartman »

Das ist ein Fall für den Abschnitt 5.8 "Grouping plots". Soweit ich das Beispiel überblicke, kannst Du alle notwendigen Einstellungen im optionalen Argument der groupplot-Umgebung tätigen. Das gilt auch für die Option im Abschnitt 4.2 "The Axis Environments", mit deren Hilfe sich die Umgebung für die logarithmische Skalierung der y-Achse ersetzen lässt.

Du darfst übrigens pgf und tikz aus der Präambel entfernen, da beide schon durch pgfplots bereitgestellt werden.


Benni1050
Forum-Newbie
Forum-Newbie
Beiträge: 6
Registriert: Mi 31. Jan 2018, 13:56

Re: pgfplots/tikz: Anordnung mehrerer Diagramme im 2x2-Raster mit teilweisem Verzicht auf tick labels

Beitrag von Benni1050 »

Hallo Bartman,

ich danke Dir sehr für die hilfreiche Antwort einschließlich des zusätzlichen Hinweises bzgl. der logarithmischen Skalierung.

Als nun funktionierendes Beispiel sieht das jetzt übrigens so aus:

\documentclass[paper = a4,12pt]{scrreprt}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.17}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 2,x descriptions at=edge bottom,y descriptions at=edge left,horizontal sep=1cm,vertical sep=1cm,},ymode=log,log ticks with fixed point,scale only axis, width=1/3*\textwidth,xlabel=Test,ylabel=Test,xmin=0,xmajorgrids,xmax=100,ymajorgrids,,ymax=100,ymin=0.01,]
\nextgroupplot
	\addplot coordinates{(1,10) (20,30) (50,40)};
\nextgroupplot
	\addplot coordinates{(1,10) (20,30) (50,40)};
\nextgroupplot
	\addplot coordinates{(1,10) (20,30) (50,40)};
\nextgroupplot
	\addplot coordinates{(1,10) (20,30) (50,40)};
\end{groupplot}
\end{tikzpicture}
\end{center}
\end{document}

Gruß

Benni


Antworten