I am plotting a function with pgfplots and I get an overlap of the function with a number on the axis like this:
This is the code I am using:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
%\pgfplotsset{width=8cm,compat=1.3}
\pgfplotsset{compat=1.3,
every mark/.append style={scale=1},
scale only axis,
}
\usetikzlibrary{arrows}
\tikzset{shorten <>/.style = {shorten <=#1, shorten >=#1}}
\usepackage{float}
\usepackage{graphicx}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
height=3cm,
width=0.4\textwidth,
grid,
grid style = {dashed},
axis lines=middle,
xlabel=$x$, xlabel style={anchor=west},
ylabel=$f(x)$, ylabel style={anchor=south},
xmin=-4, xmax=4,
ymin=-0.7, ymax=0.7
]
\addplot [thick,-o, shorten <>=-3.8\pgflinewidth]
coordinates { (-5,0.5) (0,0.5)};
\addplot [thick,mark=*]
coordinates {(0,0)};
\addplot [thick,o-, shorten <>=-3.8\pgflinewidth]
coordinates {(0,-0.5) (5,-0.5)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Is there any way to make this prettier?