summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgfplots/test/pgfplotstest/pgfplotstest.align.tex
blob: 036ee5c71a02b28c0a4fa44d0fbca3846cedf813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
\testfile{pgfplotstest.align.tex}
\testsection{Anchors, alignment, baselines, sub nodes}%
\testsubsection{Baseline alignment}
\noindent
\begin{tikzpicture}[baseline]
	\begin{axis}[width=0.4\linewidth,xlabel=An x label]
		\smallplotstest
	\end{axis}
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}[baseline]
	\begin{axis}[width=0.4\linewidth,xlabel={\Huge An x label}]
		\smallplotstest
	\end{axis}
\end{tikzpicture}

\testsubsection{Baseline alignment and externalized graphics}
One needs \texttt{\textbackslash beginpgfgraphicnamed} around the complete paragraph, so this here doesn't work (see source code):

\beginpgfgraphicnamed{baselinetesta}
\begin{tikzpicture}[baseline]
\begin{axis}[width=0.4\linewidth,xlabel=An x label]
	\smallplotstest
\end{axis}
\end{tikzpicture}
\endpgfgraphicnamed
%
%
\hspace{1cm}
\beginpgfgraphicnamed{baselinetestb}
\begin{tikzpicture}[baseline]
\begin{axis}[width=0.4\linewidth,xlabel={\Huge An x label}]
	\smallplotstest
\end{axis}
\end{tikzpicture}
\endpgfgraphicnamed

\testsubsection{Baseline alignment and externalized graphics II}
\beginpgfgraphicnamed{baselinetestc}
\begin{tikzpicture}[baseline]
\begin{axis}[width=0.4\linewidth,xlabel=An x label]
	\smallplotstest
\end{axis}
\end{tikzpicture}
%
%
\hspace{1cm}
\begin{tikzpicture}[baseline]
\begin{axis}[width=0.4\linewidth,xlabel={\Huge An x label}]
	\smallplotstest
\end{axis}
\end{tikzpicture}
\endpgfgraphicnamed

\testsubsection{Horizontal and Vertical alignment}
\begin{tikzpicture}[baseline]
\begin{axis}[width=0.4\linewidth,xlabel=An x label,ylabel=An y label]
	\smallplotstest
\end{axis}

\begin{scope}[yshift=-4cm]
\begin{axis}[width=0.4\linewidth,xlabel=An x label,ylabel={$\displaystyle\sum_{k=1}^n \frac 1n$}]
	\smallplotstest
\end{axis}
\end{scope}

\node[fill=yellow,circle] at (0,0) {$(0,0)$};
\end{tikzpicture}
%
%
\hspace{1cm}
\begin{tikzpicture}[baseline]
\begin{axis}[width=0.4\linewidth,xlabel={\Huge An x label}]
	\smallplotstest
\end{axis}

\begin{scope}[yshift=-4cm]
\begin{axis}[width=0.4\linewidth,xlabel={\Huge An x label},ylabel={$\displaystyle\sum_{k=1}^n \frac 1n$}]
	\smallplotstest
\end{axis}
\end{scope}
\node[fill=yellow,circle] at (0,0) {$(0,0)$};
\end{tikzpicture}

\testsubsection{Anchortest}
{
\setlength{\fboxsep}{0pt}%
\def\plot#1{
	\vbox{\hsize=5cm
	#1:

	\pgfplotsset{every axis legend/.append style={at={(1.03,1)},anchor=north west}}
	\fbox{%
	\begin{tikzpicture}
		\begin{axis}[
			width=5cm,
			anchor=#1,
			title=My title,
			xlabel=$x$,
			ylabel=$y$
		]
			\smallplotstest
			\addlegendentry{My plot}
		\end{axis}
		\begin{pgfinterruptboundingbox}
		\node[fill=yellow,circle] at (0,0) {$(0,0)$};
		\end{pgfinterruptboundingbox}
	\end{tikzpicture}
	}%
	}
}%
\plot{outer center}
\plot{outer north}
\plot{outer north east}
\plot{outer east}
\plot{outer south east}
\plot{outer south}
\plot{outer south west}
\plot{outer west}
\plot{outer north west}
\plot{center}
\plot{north}
\plot{north east}
\plot{east}
\plot{south east}
\plot{south}
\plot{south west}
\plot{west}
\plot{north west}
\plot{above north}
\plot{above north east}
\plot{right of north east}
\plot{right of east}
\plot{right of south east}
\plot{below south east}
\plot{below south}
\plot{below south west}
\plot{left of south west}
\plot{left of west}
\plot{left of north west}
\plot{above north west}
}


\testsubsection{Accessing sub-nodes}
\begin{tikzpicture}[baseline]%
	\node[circle,draw=black] at (0,0) {Origin};
	\begin{loglogaxis}[
		anchor=north,
		name=firstplot,
		xlabel=Cost,
		ylabel=Error,
		y label style={name=myylabel},
		x label style={name=myxlabel},
		legend style={name=mylegend,
			row 1 column 2/.style={blue,name=firstentry}% doesn't work!
		}
	]
	\addplot plot coordinates {
		(5,     8.31160034e-02)
		(17,    2.54685628e-02)
		(49,    7.40715288e-03)
		(129,   2.10192154e-03)
		(321,   5.87352989e-04)
		(769,   1.62269942e-04)
		(1793, 4.44248889e-05)
		(4097, 1.20714122e-05)
		(9217, 3.26101452e-06)
	};
	\addplot plot coordinates {
		(7,     8.47178381e-02)
		(31,    3.04409349e-02)
		(111,   1.02214539e-02)
		(351,   3.30346265e-03)
		(1023,  1.03886535e-03)
		(2815,  3.19646457e-04)
		(7423,  9.65789766e-05)
		(18943, 2.87339125e-05)
		(47103, 8.43749881e-06)
	};
	\legend{Case 1\\Case 2\\}
	\end{loglogaxis}

	\node[pin=45:legend] at (mylegend.center) {};
	\node[pin=-45:x label] at (myxlabel.center) {};
	\node[pin=180:y label] at (myylabel.center) {};
\end{tikzpicture}%


\testsubsection{Funny bounding boxes}
\testsubsubsection{(my plot.below south west) rectangle (my plot.above north east)}
{
The following figure is centered:
\setlength{\fboxsep}{0pt}%
\begin{center}
\fbox{%
\begin{tikzpicture}%
	\begin{pgfinterruptboundingbox}
	\pgfplotsset{every axis legend/.append style={at={(1.03,1)},anchor=north west}}
	\begin{axis}[
		name=my plot,
		title=A title,
		xlabel={\Huge An x label},
		ylabel={$\displaystyle\sum_{k=1}^n \frac 1n$}
	]
		\smallplotstest
		\addlegendentry{My plot}
	\end{axis}
	\end{pgfinterruptboundingbox}

	\useasboundingbox (my plot.below south west) rectangle (my plot.above north east);
\end{tikzpicture}%
}%
\end{center}
}