длина вывода pgfplot

длина вывода pgfplot

Рассмотрим следующий пример из pgfplotруководства.

\begin{tikzpicture}
  \tikzset{
    every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
    small dot/.style={fill=black,circle,scale=0.3}
  }
  \begin{axis}[
    clip=false,
    title=How \texttt{axis description cs} works
  ]
  \addplot {x};

  \node[small dot,pin=120:{$(0,0)$}]
  \node[small dot,pin=-30:{$(1,1)$}]
  \node[small dot,pin=-90:{$(1.03,0.5)$}]
  \node[small dot,pin=125:{$(0.5,0.5)$}]
  \end{axis}
\end{tikzpicture}

Этот код дает следующее изображение

изображение, полученное с помощью кода выше

То, что я хочу изменить и не смог найти в руководстве, это изменить длину пинов. Например, сделать так, чтобы текст пина в середине казался ближе к значению 5 оси Y и сделать соединительную линию протяженностью до этой точки. Результат, который я хочу, показан на следующем рисунке.

введите описание изображения здесь

Возможно ли это как-то?

решение1

Вы можете использовать pin distance:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \tikzset{
    every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
    small dot/.style={fill=black,circle,scale=0.3}
  }
  \begin{axis}[
    clip=false,
    title=How \texttt{axis description cs} works
  ]
  \addplot {x};

  \node[small dot,pin=120:{$(0,0)$}] at (axis description cs:0,0) {};
  \node[small dot,pin=-30:{$(1,1)$}] at (axis description cs:1,1) {};
  \node[small dot,pin={[pin distance=2cm]125:{$(0.5,0.5)$}}] at (axis description cs:0.5,0.5) {};
  \end{axis}
\end{tikzpicture}

\end{document}

введите описание изображения здесь

Связанный контент