Improve this TikZ picture
The little lines are drawn by the for loop in your code. If you don't want them outside of the axis, don't let the loop run from -3 to 3, but only from -2 to 2.
If you also want to remove the lines from the edges of your axis, restrict the loop further to -1 to 1 (or remove them completely, the remaining ticks are not really visible above the edge of the rectangle)
Furthermore there are missing ,
, that is why some of the lines are missing. Also the syntax for syntax for drawing the rectangle (and other geometric shapes, see @marmot's comment below) can be simplified.
\documentclass[12pt]{book}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw[line width=.8pt,->] (-2,0.) -- node[pos=1,right]{}(2,0);
\foreach \x in {-2,-1,1,2}{
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
}
\draw[line width=.8pt,->] (0.,-2) -- node[pos=1,above]{}(0,2);
\foreach \t in {-2,-1,1,2}{
\draw[shift={(0,\t)},color=black] (2pt,0pt) -- (-2pt,0pt);
}
\draw[pattern=north west lines] (-1,-1) rectangle (1,1);
\end{tikzpicture}
\end{document}
I don't know if that what is wanted?
\documentclass[12pt]{book}
\usepackage{tikz}
\usetikzlibrary{patterns,shapes.geometric}
\begin{document}
\begin{tikzpicture}
\draw[line width=.8pt,->] (-2,0.) -- node[pos=1,right]{}(2,0);
%\foreach \x in {-3,-2-1,1,2,3}
%raw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) ;
\draw[line width=.8pt,->] (0.,-2) -- node[pos=0.75,above right]{1}(0,2);
%\foreach \t in {-3,-2,-1,1,2,3}
%\draw[shift={(0,\t)},color=black] (2pt,0pt) -- (-2pt,0pt) ;
\draw[pattern=north west lines] (-1,1)--(1,1)--(1,-1)--(-1,-1)--(-1,1);
\node at (0,-2.25){$d_{\infty}$}; % <---------------
\end{tikzpicture}
\begin{tikzpicture}
\draw[line width=.8pt,->] (-2,0.) -- node[pos=0.75,above right]{1}(2,0); % <----------- modified
%\foreach \x in {-3,-2-1,1,2,3}
%\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) ;
\draw[line width=.8pt,->] (0.,-2) -- node[pos=0.75,above right]{1}(0,2); %<-------- modified
%\foreach \t in {-3,-2,-1,1,2,3}
%\draw[shift={(0,\t)},color=black] (2pt,0pt) -- (-2pt,0pt) ;
\draw[pattern=north west lines] (0,0) circle (1 cm);
\node at (0,-2.25){$d_{\infty}$};
\end{tikzpicture}
\begin{tikzpicture}
\draw[line width=.8pt,->] (-2,0.) -- node[pos=0.75,above right]{1}(2,0); % <---------- modified
%\foreach \x in {-3,-2-1,1,2,3}
%\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) ;
\draw[line width=.8pt,->] (0.,-2) -- node[pos=0.75,above right]{1}(0,2); %<------- modified
%\foreach \t in {-3,-2,-1,1,2,3}
%\draw[shift={(0,\t)},color=black] (2pt,0pt) -- (-2pt,0pt) ;
\draw[pattern=north west lines] (0,1)--(1,0)--(0,-1)--(-1,0)--(0,1);
\node at (0,-2.25){$d_{\infty}$};
\end{tikzpicture}
\end{document}