I have two graphs drawn using pgfplots
. The graphs are drawn as I would like them to be drawn, and the x
-axes are aligned, as I would like them to be aligned. There are three modifications that I need. First, the two graphs should be horizontally centered. Second, more (horizontal) space is needed between the two graphs. Third, a title needs to be centered over the y
-axis of each graph. Something like the following code would be suitable.
\node[align=center, font=\bfseries, inner sep=0pt, above=3mm] at (current bounding box.north) {The graph of an \\ increasing function};
\node[align=center, font=\bfseries, inner sep=0pt, above=3mm] at (current bounding box.north) {The graph of a strictly \\ increasing function};
By the way, in the first graph, I have a horizontal line drawn along the x
-axis between the origin and (1,0)
. Are the axes drawn with a width of 0.8pt
? I used the option line width=1.2pt
to draw this horizontal line. Is that typical when "drawing over" the axes?
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=3in,axis equal image, clip=false,
xmin=-4,xmax=4,
ymin=-4,ymax=4,
restrict y to domain=-4:4,
%enlargelimits={abs=1cm},
xtick={\empty},ytick={\empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=$x$,ylabel=$y$,
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot [domain=-3:-2] {-3};
\addplot [domain=-2:-1] {-2};
\addplot [domain=-1:0] {-1};
\addplot [line width=1.2pt, domain=0:1] {0};
\addplot [domain=1:2] {1};
\addplot [domain=2:3] {2} node [pos=1, anchor=south west, font=\footnotesize] {$y=f(x)$};
\draw[fill] (-3,-3) circle [radius=1.5pt];
\draw[fill] (-2,-2) circle [radius=1.5pt];
\draw[fill] (-1,-1) circle [radius=1.5pt];
\draw[fill] (0,0) circle [radius=1.5pt];
\draw[fill] (1,1) circle [radius=1.5pt];
\draw[fill] (2,2) circle [radius=1.5pt];
\draw [fill=white] (-2,-3) circle [radius=1.5pt];
\draw [fill=white] (-1,-2) circle [radius=1.5pt];
\draw [fill=white] (0,-1) circle [radius=1.5pt];
\draw [fill=white] (1,0) circle [radius=1.5pt];
\draw [fill=white] (2,1) circle [radius=1.5pt];
\draw [fill=white] (3,2) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}
%
%
\begin{tikzpicture}
\begin{axis}[width=3in, clip=false,
xmin=-3,xmax=3,
ymin=-10,ymax=10,
restrict y to domain=-8:8,
% enlargelimits={abs=1cm},
xtick={\empty},ytick={\empty},
axis lines=middle,
axis line style={latex-latex},
xlabel=$x$,ylabel=$y$,
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot [domain=-2:2] {x^3} node [pos=1, anchor=west, font=\footnotesize] {$y=g(x)$};
\end{axis}
\end{tikzpicture}
\end{document}