PGFplots in Kombination mit subcaption

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: PGFplots in Kombination mit subcaption

von Udo » Mo 13. Mär 2017, 12:48

Hallo,

Danke, so funktioniert es zwar, aber ich habe mehrere tausend Messwerte und kann nicht überall händisch dieses \\ hinzufügen.

Ich habe jetzt subcaptionbox durch
\begin{subfigure}[b]{.49\linewidth}
\centering\large A
\caption{A subfigure}\label{fig:1a}
\end{subfigure}%
ersetzt. Damit tritt komischerweise kein Fehler auf.
Verglichen zu subcaptionbox dürfte das ja kein Unterschied machen, oder?

Gruß Udo

von Bartman » Mo 13. Mär 2017, 12:29

Mein Beispiel funktioniert bei Overleaf. Auf meinem aktuellen MiKTeX-System habe ich es nicht getestet.
\documentclass{article}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc} 
\usepackage{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[!htb]
   \centering
   \subcaptionbox{Bild1\label{bild1}}{%
   \begin{tikzpicture}
   \begin{axis}[enlargelimits=0.2]
      \addplot+[nodes near coords,only marks,point meta=explicit symbolic,table/row sep=crcr] table[meta=label] {
      x    y   label\\
      0.5  0.2 1\\
      0.2  0.1 t2\\
      0.7  0.6 3\\
      0.35 0.4 Y4\\
      0.65 0.1 5\\
      };
      \end{axis}
   \end{tikzpicture}
   }%
   \subcaptionbox{Bild2\label{bild2}}{%
   \begin{tikzpicture}
   \begin{axis}[enlargelimits=0.2]
      \addplot+[nodes near coords,only marks,point meta=explicit symbolic,table/row sep=crcr] table[meta=label] {
      x    y   label\\
      0.5  0.2 1\\
      0.2  0.1 t2\\
      0.7  0.6 3\\
      0.35 0.4 Y4\\
      0.65 0.1 5\\
      };
      \end{axis}
   \end{tikzpicture}
   }%
   \caption{TestCap}
\end{figure}
\end{document}
Quelle: http://tex.stackexchange.com/questions/331275

PGFplots in Kombination mit subcaption

von Udo » Mo 13. Mär 2017, 11:55

Hallo,

ich möchte mit dem Paket "subcaption" zwei pgfplots nebeneinander setzen.

Wenn ich das mache:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc} 
\usepackage{subcaption}
\usepackage{tikz} 
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[!htb]
	\centering
	\subcaptionbox{Bild1\label{bild1}}{%
	\begin{tikzpicture}
	\begin{axis}[enlargelimits=0.2]
		\addplot+[nodes near coords,only marks,point meta=explicit symbolic] table[meta=label] {
		x    y   label
		0.5  0.2 1
		0.2  0.1 t2
		0.7  0.6 3
		0.35 0.4 Y4
		0.65 0.1 5
		};
		\end{axis}
	\end{tikzpicture}
	}%
	\subcaptionbox{Bild2\label{bild2}}{%
	\begin{tikzpicture}
	\begin{axis}[enlargelimits=0.2]
		\addplot+[nodes near coords,only marks,point meta=explicit symbolic] table[meta=label] {
		x    y   label
		0.5  0.2 1
		0.2  0.1 t2
		0.7  0.6 3
		0.35 0.4 Y4
		0.65 0.1 5
		};
		\end{axis}
	\end{tikzpicture}
	}%
	\caption{TestCap}
\end{figure}
\end{document}
kommt der Fehler:
Package pgfplots Error: Could not read table file '" x y label 0 .5 0.2 1 0.2 0.1 t2 0.7 0.6 3 0.35 0.4 Y4 0.65 0.1 5 "' in 'search path=.'. In case you intended to provide inline data: maybe TeX screwed up your end-of-line s? Try `row sep=crcr' and terminate your lines with `\\' (refer to the pgfplots table manual for details). 
Das merkwürdige ist, dass die beiden pgfplots aus der Doku sind und ohne subcaption auch problemlos laufen. Kommentiert man also die zwei Zeilen mit subcaptionbox und der schließenden Klammer aus, funktioniert es:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc} 
\usepackage{subcaption}
\usepackage{tikz} 
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[!htb]
	\centering
	%\subcaptionbox{Bild1\label{bild1}}{%
	\begin{tikzpicture}
	\begin{axis}[enlargelimits=0.2]
		\addplot+[nodes near coords,only marks,point meta=explicit symbolic] table[meta=label] {
		x    y   label
		0.5  0.2 1
		0.2  0.1 t2
		0.7  0.6 3
		0.35 0.4 Y4
		0.65 0.1 5
		};
		\end{axis}
	\end{tikzpicture}
	%}%
	%\subcaptionbox{Bild2\label{bild2}}{%
	\begin{tikzpicture}
	\begin{axis}[enlargelimits=0.2]
		\addplot+[nodes near coords,only marks,point meta=explicit symbolic] table[meta=label] {
		x    y   label
		0.5  0.2 1
		0.2  0.1 t2
		0.7  0.6 3
		0.35 0.4 Y4
		0.65 0.1 5
		};
		\end{axis}
	\end{tikzpicture}
	%}%
	\caption{TestCap}
\end{figure}
\end{document}
Weiß jemand, warum das so ist?

Gruß Udo

Nach oben