2

Following the answer of @Jake to the question \addplot and \draw, I set up the following code:

\documentclass{standalone}
\usepackage{tikz, pgfplots}
\def\points{
  (1, 1)
  (2, 2)
  }
\begin{document}
\begin{tikzpicture}
  \draw[thick, color=red](1, 1) -- (2, 2);
  \begin{axis}[anchor = origin, x = 1cm, y = 1cm, hide axis]
    \addplot [color = blue] coordinates {\points};
  \end{axis}
\end{tikzpicture}
\end{document}

The result is

enter image description here

Obviously the axis and \tikzpicture are not properly aligned. What is wrong?

2

Setting xmin=0, ymin=0 fixes the issue:

\documentclass{standalone}
\usepackage{tikz, pgfplots}
\def\points{
  (1, 1)
  (2, 2)
  }
\begin{document}
\begin{tikzpicture}
  \draw[thick, color=red](1, 1) -- (2, 2);
  \begin{axis}[anchor = origin, x = 1cm, y = 1cm, hide axis, xmin=0, ymin=0]
    \addplot [color = blue] coordinates {\points};
  \end{axis}
\end{tikzpicture}
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.