4

The backside of a review worksheet for Pre-calculus 12

\begin{figure}[!ht]
\centering
\begin{tikzpicture}
\begin{axis}[
width = 12cm,
height = 12cm,
axis y line = middle, 
axis x line = middle,
grid style = {dashed, gray!50},  
grid = both, % Switch on the grid lines
%ymajorgrids = true,
%xmajorgrids = true,  
minor ytick = {-7,-6,...,3},
minor xtick = {-5,-4,...,5},
xmin = -5,
xmax = 5,
ymin = -7,
ymax = 3,    
xlabel = $x$,
ylabel = $y$,
]
\node at (axis cs:-2.45,-5) [blue]{$\bullet$};
\node at (axis cs:2.45,-5) [blue]{$\bullet$};
\addplot[smooth, blue, thick, domain = -2.45:2.45] {-x^2 + 1};
\end{axis}
\end{tikzpicture}
\caption*{The domain is $-2.4 \leqslant x \leqslant 2.4$. The range is $-5 \leqslant y \leqslant 1$. \\ It is a function.}
\end{figure}

I am recreating a worksheet to prove I know the domain and range of various functions. The code I have provided gives the example of one function shown in the picture. Could someone show me how to arrange 9 figures on a page evenly spaced out and use the figure in my code as an example?

3 Answers 3

2

I assume that you're satisfied with the code you have for the nine plots, and hence that the remaining task is to group the nine plots on a page. I suggest you create a dedicated environment called, say, "smallpic" to house each file and associated text. That way, you can save yourself a lot of repetitive typing.

enter image description here

\documentclass[12pt]{article}

\usepackage[demo]{graphicx} % remove 'demo' option in real document
\usepackage{caption}
\newenvironment{smallpic}{\begin{minipage}{0.3\textwidth}\small}
  {\end{minipage}}

\usepackage{pgfplots}

\begin{document}

\begin{figure}
\caption{Nine graphs} \label{fig:ninegraphs}

\begin{smallpic}  % Fig. 1

\begin{tikzpicture}
\begin{axis}[
width = 5.6cm,
height = 5cm,
axis y line = middle, 
axis x line = middle,
grid style = {dashed, gray!50},  
grid = both, % Switch on the grid lines
%ymajorgrids = true,
%xmajorgrids = true,  
minor ytick = {-7,-6,...,3},
minor xtick = {-5,-4,...,5},
xmin = -5,
xmax = 5,
ymin = -7,
ymax = 3,    
%xlabel = $x$,
%ylabel = $y$,
]
\node at (axis cs:-2.45,-5) [blue]{$\bullet$};
\node at (axis cs:2.45,-5) [blue]{$\bullet$};
\addplot[smooth, blue, thick, domain = -2.45:2.45] {-x^2 + 1};
\end{axis}
\end{tikzpicture}

D: $-2.4 \leq x \leq 2.4$

R: $-5 \leq y \leq 1$

This is a parabola.
\end{smallpic}
\hspace{\fill}
\begin{smallpic}
\includegraphics[width=\linewidth]{fig2}
D:

R:

Function ?
\end{smallpic}
\hspace{\fill}
\begin{smallpic}
\includegraphics[width=\linewidth]{fig3}
D:

R:

Function ?
\end{smallpic}
\bigskip\bigskip


\begin{smallpic}
\includegraphics[width=\linewidth]{fig4}
D:

R:

Function ?
\end{smallpic}
\hspace{\fill}
\begin{smallpic}
\includegraphics[width=\linewidth]{fig5}
D:

R:

Function ?
\end{smallpic}
\hspace{\fill}
\begin{smallpic}
\includegraphics[width=\linewidth]{fig6}
D:

R:

Function ?
\end{smallpic}
\bigskip\bigskip


\begin{smallpic}
\includegraphics[width=\linewidth]{fig7}
D:

R:

Function ?
\end{smallpic}
\hspace{\fill}
\begin{smallpic}
\includegraphics[width=\linewidth]{fig8}
D:

R:

Function ?
\end{smallpic}
\hspace{\fill}
\begin{smallpic}
\includegraphics[width=\linewidth]{fig9}
D:

R:

Function ?
\end{smallpic}

\end{figure}
\end{document}
6
  • Oh they are not images though. They are graphs so how would i made my code for example show in the place of figure one?
    – David
    Oct 29, 2014 at 3:19
  • @David - You'd replace the \includegraphics[width=\linewidth]{...} statements with the applicable TikZ code. I've updated my example to include a slightly modified version of your plot in the upper-left position. I didn't have information about the actual dimensions of your page, so I've put in my best guess for the values of the width and height of each plot.
    – Mico
    Oct 29, 2014 at 6:20
  • Ok perfect. This really helped.
    – David
    Oct 29, 2014 at 6:27
  • The dimensions are just like default I guess. Like default size for printing paper.
    – David
    Oct 29, 2014 at 6:28
  • @David - There are (at least!) two "default sizes" for printing paper: A4 and (US) Letter; their widths and heights differ. The width available for printing is also affected by the margin settings -- are the margins 1" wide, or something else?
    – Mico
    Oct 29, 2014 at 6:31
4

You can use minipages to place the text within 0.3\linewdith and use \resizebox{}{}{} to scale the figure to fit in the minipage:

enter image description here

Notes:

  • As you don't want the images to float don't use a floating environment such as figure.
  • The captions should be added outside of the \resizebox{}{}{} so that the text is not scaled.
  • \vfill was used to vertically spread out the figures.
  • The showframe package was used just to show the page margins. It is not needed in your actual use case.

Code:

\documentclass{article}

\usepackage{graphics}
\usepackage{pgfplots}
\usepackage{caption}
\usepackage{showframe}
\pgfplotsset{compat=1.11}

\newcommand*{\MyFig}{%
\begin{tikzpicture}
\begin{axis}[
width = 12cm,
height = 12cm,
axis y line = middle, 
axis x line = middle,
grid style = {dashed, gray!50},  
grid = both, % Switch on the grid lines
%ymajorgrids = true,
%xmajorgrids = true,  
minor ytick = {-7,-6,...,3},
minor xtick = {-5,-4,...,5},
xmin = -5,
xmax = 5,
ymin = -7,
ymax = 3,    
xlabel = $x$,
ylabel = $y$,
]
\node at (axis cs:-2.45,-5) [blue]{$\bullet$};
\node at (axis cs:2.45,-5) [blue]{$\bullet$};
\addplot[smooth, blue, thick, domain = -2.45:2.45] {-x^2 + 1};
\end{axis}
\end{tikzpicture}%
}

\begin{document}\noindent
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\hfill
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\hfill
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\vfill
\noindent
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\hfill
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\hfill
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\vfill
\noindent
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\hfill
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\hfill
\begin{minipage}{0.3\linewidth}
\resizebox{\linewidth}{!}{\MyFig}%
\captionof{figure}{The domain is $-2.4 \le x \le 2.4$. The range is $-5 \le y \le 1$.  It is a function.}%
\end{minipage}%
\end{document}
3
  • This really helped! One thing though, my console tells me it doesn't recognize \pgfplotsset{compat=1.11} do you know why?
    – David
    Oct 28, 2014 at 5:11
  • Oh and also, when I input your code, it encloses the graph very tightly with two random rectangles, one on top and one on the right side. I just want the 9 figures without being trapped in anything. I just the 9 figures. Hope you can help
    – David
    Oct 28, 2014 at 5:28
  • @David: You probably have an older package, so you can eliminate the \pgfplotsset. The box is from the showframe package -- just eliminate that as per the "Notes" section. Oct 28, 2014 at 5:35
3

If you are plotting everything, then use groupplots

 \documentclass[margin=5mm]{standalone}
        \usepackage{pgfplots}
        \usetikzlibrary{positioning}
        \usepgfplotslibrary{groupplots}
        \pgfplotsset{compat=1.11}
        \begin{document}

        \begin{tikzpicture}
                \begin{groupplot}[group style={group name=my plots,group size= 3 by 3,vertical sep=2.5cm },height=5cm,width=6.4cm]
                        \nextgroupplot[title=type1,ylabel={Range1 }]
                                        \addplot[blue] {x};\label{plots:plot1}
                                        \addplot[red] {x²};\label{plots:plot2}
                                        \addplot[green] {2*x};\label{plots:plot3}

                        \nextgroupplot[title=type2]
                                        \addplot[blue]{x};
                        \nextgroupplot[title=type3,]
                                        \addplot[blue]{x};
                        \nextgroupplot[ylabel={Range2 }]
                                        \addplot[blue]{x};
                        \nextgroupplot
                                        \addplot[blue]{x};
                        \nextgroupplot
                                        \addplot[blue]{x};
                        \nextgroupplot[xlabel={x label},ylabel={Range4 }]
                                        \addplot[blue]{x};
                        \nextgroupplot[xlabel={x label}]
                                        \addplot[blue]{x};
                        \nextgroupplot[xlabel={x label}]
                                        \addplot[blue]{x};

                \end{groupplot}
                \node[below = 0.5cm of my plots c1r1.south,align=left] {(a)\\Function\\some};
                \node[below = 0.5cm of my plots c2r1.south] {(b)};
                \node[below = 0.5cm of my plots c3r1.south] {(c)};
                \node[below = 0.5cm of my plots c1r2.south] {(d)};
                \node[below = 0.5cm of my plots c2r2.south] {(e)};
                \node[below = 0.5cm of my plots c3r2.south] {(f)};
                \node[below = 0.9cm of my plots c1r3.south] {(g)};
                \node[below = 0.9cm of my plots c2r3.south] {(h)};
                \node[below = 0.9cm of my plots c3r3.south] {(h)};

        \end{tikzpicture}
        \end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .