\documentclass[border=3mm]{standalone} \usepackage{pgfplots-autonode} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ width=13cm,height=9cm, xmin=-4,xmax=4,ymin=-4,ymax=4, axis equal image,grid=both, xlabel={$x$},ylabel={$y$}, auto node placement, auto node algorithm=repair, auto node bbox mode=oriented, auto node failure mode=error, auto node candidates=81 ] \foreach \b in {-3,-2,...,3}{ \addplot[blue!70!black,domain=-4:4,samples=2] {x+\b} \pgfplotsautonode[preferred pos=.5,sloped=true, node options={fill=white,fill opacity=.9,text opacity=1}]{$+$}; \addplot[red!75!black,domain=-4:4,samples=2] {-x+\b} \pgfplotsautonode[preferred pos=.5,sloped=true, node options={fill=white,fill opacity=.9,text opacity=1}]{$-$}; } \end{axis} \end{tikzpicture} \end{document} .