\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{autonode}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  width=8cm,height=5cm,
  xmin=0,xmax=1,ymin=0,ymax=1,
  auto node placement,
  auto node debug=summary,
  auto node failure mode=error,
  clip=true]
  % The explicit TikZ padding overrides the smaller autonode default.
  \addplot[blue,domain=0:1,samples=21] {0.3}
    \pgfplotsautonode[
      preferred pos=.1,
      node options={fill=yellow,inner sep=20pt}] {X};
  % A west-anchored, width-constrained node extends to the right of its
  % placement coordinate; its paragraph width must enter the same measurement.
  \addplot[red,domain=0:1,samples=21] {0.75}
    \pgfplotsautonode[
      preferred pos=.9,
      node options={anchor=west,fill=cyan!20,inner sep=5pt,
        text width=25mm,align=center}]
      {wide anchored label};
\end{axis}
\end{tikzpicture}
\end{document}
