Legendeneinträge rechtsbündig anordnen

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: Legendeneinträge rechtsbündig anordnen

von kannstmasehn » Di 5. Sep 2017, 07:45

Danke. Passt!

von esdd » Mo 4. Sep 2017, 23:46

Nimm every even column/.style={anchor=base east}, also
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplots}% lädt auch tikz
\pgfplotsset{compat=newest}% direkt nach dem Laden von pgfplots setzen
\usetikzlibrary{matrix,positioning}
\usepgfplotslibrary{groupplots}

\begin{document}
   \begin{tikzpicture}
   \begin{groupplot}[group style={group size= 2 by 1}]
   \nextgroupplot   
   \addplot table[row sep=crcr]{%
      50   1.08606985986195\\
      69.7   1.0301192219201\\
   }; \label{plots:plot1}
   
   \addplot table[row sep=crcr]{%
      50   15.3733528550512\\
      69.7   11.8045387994143\\
   }; \label{plots:plot2}
   
   \addplot table[row sep=crcr]{%
      50   69.2846684793976\\
      69.7   53.5975737293453\\
   }; \label{plots:plot3}

   \addplot table[row sep=crcr]{%
   50   90\\
   69.7   70\\
   }; \label{plots:plot4}

   
   \coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot
   
   \nextgroupplot   
   \addplot table[row sep=crcr]{%
      50   1.20572658060245\\
      69.7   1.09731876861966\\
   };
   
   \addplot table[row sep=crcr]{%
      50   23.1876861966236\\
      69.7   17.9245283018868\\
   };
   
   \addplot table[row sep=crcr]{%
      50   110.228401191658\\
      69.7   84.5746441575637\\
   };
   
   \addplot table[row sep=crcr]{%
      50   90\\
      69.7   70\\
   }; 
   
   \coordinate (bot) at (rel axis cs:1,0);% coordinate at bottom of the last plot
   \end{groupplot}

   \path (top|-current bounding box.south)--
   coordinate(legendpos)
   (bot|-current bounding box.south);
   \matrix[
   matrix of nodes,
   draw,
   every even column/.style={anchor=base east},
   ]at([yshift=-5ex]legendpos)
   {
      \ref{plots:plot1}& blaaaaa&[5pt] 
      \ref{plots:plot2}& blaaaaa&[5pt] \\
      \ref{plots:plot3}& blub&[5pt]
      \ref{plots:plot4}& blub&[5pt]      
      \\};
   \end{tikzpicture}
\end{document}
[/code]

von kannstmasehn » Mo 4. Sep 2017, 15:48

Danke dir. Funktioniert bei zwei Spalten leider nur für die erste. Wie kann ich das auch bei der zweiten, bzw. bei einer dritten oder allen Spalten umsetzen? Zumal da noch hinzukommt, dass der Legendeneintrag nicht mehr auf der gleichen Höhe wie das Legendensymbol ist.
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{matrix,positioning}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}
%\usepackage{tikz}

\begin{document}

	\begin{tikzpicture}
	\begin{groupplot}[group style={group size= 2 by 1}]
	\nextgroupplot	
	\addplot table[row sep=crcr]{%
		50	1.08606985986195\\
		69.7	1.0301192219201\\
	}; \label{plots:plot1}
	
	\addplot table[row sep=crcr]{%
		50	15.3733528550512\\
		69.7	11.8045387994143\\
	}; \label{plots:plot2}
	
	\addplot table[row sep=crcr]{%
		50	69.2846684793976\\
		69.7	53.5975737293453\\
	}; \label{plots:plot3}

	\addplot table[row sep=crcr]{%
	50	90\\
	69.7	70\\
	}; \label{plots:plot4}

	
	\coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot
	
	\nextgroupplot	
	\addplot table[row sep=crcr]{%
		50	1.20572658060245\\
		69.7	1.09731876861966\\
	};
	
	\addplot table[row sep=crcr]{%
		50	23.1876861966236\\
		69.7	17.9245283018868\\
	};
	
	\addplot table[row sep=crcr]{%
		50	110.228401191658\\
		69.7	84.5746441575637\\
	};
	
	\addplot table[row sep=crcr]{%
		50	90\\
		69.7	70\\
	}; 
	
	\coordinate (bot) at (rel axis cs:1,0);% coordinate at bottom of the last plot
	\end{groupplot}

	\path (top|-current bounding box.south)--
	coordinate(legendpos)
	(bot|-current bounding box.south);
	\matrix[
	matrix of nodes,
	draw,
	column 2/.style={anchor=east},
	]at([yshift=-5ex]legendpos)
	{
		\ref{plots:plot1}& blaaaaa&[5pt] 
		\ref{plots:plot2}& blaaaaa&[5pt] \\
		\ref{plots:plot3}& blub&[5pt]
		\ref{plots:plot4}& blub&[5pt]		
		\\};
	\end{tikzpicture}
\end{document}

Danke dir!

von Bartman » Mo 4. Sep 2017, 15:42

Du könntest der \matrix das optionale Argument column 2/.style={anchor=east} hinzufügen.

Legendeneinträge rechtsbündig anordnen

von kannstmasehn » Mo 4. Sep 2017, 15:13

Hallo,

ich möchte zwei Graphen plotten und dafür lediglich eine Legende nutzen. Das habe ich so weit hinbekommen, siehe Minimalbeispiel. Nun möchte ich die Einträge in der Legende rechtsbündig anordnen. Wie kann ich das realisieren?
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{matrix,positioning}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}

\begin{document}

	\begin{tikzpicture}
	\begin{groupplot}[group style={group size= 2 by 1}]
	\nextgroupplot	
	\addplot table[row sep=crcr]{%
		50	1.08606985986195\\
		69.7	1.0301192219201\\
	}; \label{plots:plot1}
	
	\addplot table[row sep=crcr]{%
		50	15.3733528550512\\
		69.7	11.8045387994143\\
	}; \label{plots:plot2}
	
	\addplot table[row sep=crcr]{%
		50	69.2846684793976\\
		69.7	53.5975737293453\\
	}; \label{plots:plot3}

	
	\coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot
	
	\nextgroupplot	
	\addplot table[row sep=crcr]{%
		50	1.20572658060245\\
		69.7	1.09731876861966\\
	};
	
	\addplot table[row sep=crcr]{%
		50	23.1876861966236\\
		69.7	17.9245283018868\\
	};
	
	\addplot table[row sep=crcr]{%
		50	110.228401191658\\
		69.7	84.5746441575637\\
	};
	
	
	\coordinate (bot) at (rel axis cs:1,0);% coordinate at bottom of the last plot
	\end{groupplot}

	\path (top|-current bounding box.south)--
	coordinate(legendpos)
	(bot|-current bounding box.south);
	\matrix[
	matrix of nodes,
	draw,
	]at([yshift=0ex]legendpos)
	{
		\ref{plots:plot1}& blaaaaa&[5pt] \\
		\ref{plots:plot2}& blub&[5pt] \\
		\ref{plots:plot3}& bla&[5pt]
		\\};
	\end{tikzpicture}
\end{document}

Vielen Dank im Voraus.

Nach oben