summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgfplots/test/pgfplotstest/pgfplotstest.styles.tex
blob: 164ce85dc088817cb466e40286003e410a2402c4 (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
\testfile{pgfplotstest.styles.tex}
\testsection{Style--tests}
\testsubsection{Limits in `every axis'; `cycle list' option and `cycle list name' option}
{
%\tracingmacros=2\tracingcommands=2
\pgfplotsset{every linear axis/.append style={xmin=-3,xmax=3}}
\pgfplotsset{every linear axis/.append style={cycle list name={\blackwhiteplotspeclist}}}
\pgfplotsset{every loglog axis/.append style={cycle list={green\\yellow\\}}}
\begin{tikzpicture}
	\begin{axis}
		\smallplotstest
	\end{axis}
\end{tikzpicture}

\testsubsection{testing `every loglog axis' style}
\begin{tikzpicture}
	\begin{loglogaxis}
		\loglogtestplot
	\end{loglogaxis}
\end{tikzpicture}
}

\testsubsection{Using several `every ...' styles}
{
\pgfplotsset{every axis/.append style={ylabel={$L_2$ Error},line width=1pt,mark=*}}
\pgfplotsset{every axis x label/.append style={name=my x label}}
\pgfplotsset{every axis legend/.append style={legend columns=2}}
\pgfplotsset{every loglog axis/.append style={xmin=1e2,xmax=1e4}}
\begin{tikzpicture}
	\begin{loglogaxis}[xlabel={A -- quite long -- $x$ label}]
	\loglogtestplot
	\end{loglogaxis}
	\fill[red] (my x label.south east) circle(0.3cm);
\end{tikzpicture}
}

\testsubsection{Using the `style=' option}
{
\pgfkeys{/pgfplots/my personal axis/.style={ylabel=Mine!,cycle list name=\blackwhiteplotspeclist,title=My personal title,title style={font=\Huge}}}
\begin{tikzpicture}
	\begin{loglogaxis}[my personal axis]
	\loglogtestplot
	\end{loglogaxis}
\end{tikzpicture}
}

\testsubsection{legend style, grid style, x label style etc. options}
{
\pgfplotsset{every loglog axis/.append style={legend style={legend columns=2,draw=yellow}}}
\pgfplotsset{every axis/.append style={grid style={grid=major}}}
\pgfplotsset{every axis/.append style={x label style={xlabel=Dof,font=\bfseries\Huge},x tick label style={font=\large}}}
\begin{tikzpicture}
	\begin{loglogaxis}
	\loglogtestplot
	\end{loglogaxis}
\end{tikzpicture}

\testsubsection{Providing TikZ-options to either tikzpicture or axis}
\begin{tikzpicture}[color=blue]
	\begin{loglogaxis}
	\loglogtestplot
	\end{loglogaxis}
\end{tikzpicture}

\begin{tikzpicture}
	\begin{loglogaxis}[/tikz/color=blue]
	\loglogtestplot
	\end{loglogaxis}
\end{tikzpicture}
}

\testsubsection{Collecting many options together}
\begin{tikzpicture}
	\begin{axis}[
		legend style={legend columns=2},
		grid style={draw=brown},
		grid=major,
		max space between ticks=25,
		name=a styled plot,
		y tick label style={/pgf/number format/fixed zerofill,/pgf/number format/use comma,/pgf/number format/precision=3},
		tick label style={/pgf/number format/sci,/pgf/number format/sci e,font=\footnotesize},
	]

	\addplot plot[id=styledplot] function{(40*x**2 - 5*x +3)/2000};
	\addlegendentry{$\frac{1}{2000}(40x^2 - 5x +3)$}
		
	\addplot plot[id=styledplot2] function{(x**5 - 3)/2000};
	\addlegendentry{$\frac{1}{2000}(x^5 - 3)$}
		
	\end{axis}
\end{tikzpicture}

\testsubsubsection{Putting the same options into a style...}
{\pgfkeys{/pgfplots/my style/.style={
		legend style={legend columns=2},
		grid style={draw=brown},
		grid=major,
		max space between ticks=25,
		name=a styled plot,
		y tick label style={/pgf/number format/fixed zerofill,/pgf/number format/use comma,/pgf/number format/precision=3},
		tick label style={/pgf/number format/sci,/pgf/number format/sci e,font=\footnotesize},
		}
}%
\begin{tikzpicture}
	\begin{axis}[my style]

	\addplot plot[id=styledplot] function{(40*x**2 - 5*x +3)/2000};
	\addlegendentry{$\frac{1}{2000}(40x^2 - 5x +3)$}
		
	\addplot plot[id=styledplot2] function{(x**5 - 3)/2000};
	\addlegendentry{$\frac{1}{2000}(x^5 - 3)$}
		
	\end{axis}
\end{tikzpicture}

\testsubsection{Line width}
\testsubsubsection{2pt global}
{
\tikzset{every picture/.style={line width=2pt}}
\begin{tikzpicture}
	\begin{axis}[grid =major]
	\addplot coordinates {(0,0) (4,4)};
	\end{axis}
\end{tikzpicture}
}

\testsubsubsection{2pt in every axis}
{
\pgfplotsset{every axis/.append style={line width=2pt}}
\begin{tikzpicture}
	\begin{axis}[grid =major]
	\addplot coordinates {(0,0) (4,4)};
	\end{axis}
\end{tikzpicture}
}