0

The code below best reproduces the issue.

\documentclass[multi=true, crop=true]{standalone}
\usepackage{pgfplots, textcomp}
\standaloneenv{tikzpicture}
\usetikzlibrary{patterns, arrows.meta, decorations.pathreplacing, calc, matrix, positioning, angles, quotes, babel, intersections}

\pgfplotsset{compat=newest, samples=5000,
axis lines=center, axis equal,
xlabel={$x$}, ylabel={$y$},
enlarge x limits=false, enlarge x limits=false}
\begin{documment}
\begin{tikzpicture}[scale=0.75]%183
\xdef\ux{2}
\xdef\uy{1}
\xdef\vx{1}
\xdef\vy{2}
\pgfmathparse{\vy+\uy}
\xdef\sy{\pgfmathresult}
\pgfmathparse{\vx+\ux}
\xdef\sx{\pgfmathresult}
\begin{axis}[xtick=\empty, ytick=\empty, xmin=0,xmax=4, ymin=0, ymax=4,  
extra y ticks={\uy, \vy, \sy}, extra y tick labels={$y_1$, $y_2$, $y_1+y_2$},
extra x ticks={\vx, \ux, \sx}, extra x tick labels={$x_2$, $x_1$, $x_1+x_2$}]
\addplot[-latex] coordinates {(0,0)(\ux,\uy)} node[midway,below]{$\overrightarrow{u}$};
\addplot[-latex] coordinates {(0,0)(\vx,\vy)} node[midway,above]{$\overrightarrow{v}$};
\addplot[dashed] coordinates {(0,\vy)(\vx,\vy)(\vx,0)};
\addplot[dashed] coordinates {(0,\uy)(\ux,\uy)(\ux,0)};
\addplot[-latex] coordinates {(0,0)({\ux+\vx},{\uy+\vy})} node[pos=0.7,above left]{$\overrightarrow{u}+\overrightarrow{v}$};
\addplot[dashed] coordinates {(\ux,\uy)({\ux+\vx},{\uy+\vy})};
\addplot[dashed] coordinates {(\vx,\vy)({\ux+\vx},{\uy+\vy})};
\addplot[dashed] coordinates {(0,{\uy+\vy})({\ux+\vx},{\uy+\vy})({\ux+\vx},0)};
\end{axis}
\end{tikzpicture}
\end{documment}

enter image description here

The x axis should start with 0, but is starting with something else. I tried setting axis lines=center inside the axis environment too, but without effect. At another plot, the fixed length is the y axis, and I don't know why. There are some plots (I belive around 10) with the same issue.

1

Solution 1 You can just set xmin=0.8. Also replace \begin{documment} and \end{documment} with \begin{document} and \end{document}.

Input

\documentclass[multi=true, crop=true]{standalone}
\usepackage{pgfplots, textcomp}
\standaloneenv{tikzpicture}
\usetikzlibrary{patterns, arrows.meta, decorations.pathreplacing, calc, matrix, positioning, angles, quotes, babel, intersections}

\pgfplotsset{compat=newest, samples=5000,
axis lines=center, axis equal,
xlabel={$x$}, ylabel={$y$},
enlarge x limits=false, enlarge x limits=false}
\begin{document}
\begin{tikzpicture}[scale=0.75]%183
\xdef\ux{2}
\xdef\uy{1}
\xdef\vx{1}
\xdef\vy{2}
\pgfmathparse{\vy+\uy}
\xdef\sy{\pgfmathresult}
\pgfmathparse{\vx+\ux}
\xdef\sx{\pgfmathresult}
\begin{axis}[xtick=\empty, ytick=\empty, xmin=0.8,xmax=4, ymin=0, ymax=4,  
extra y ticks={\uy, \vy, \sy}, extra y tick labels={$y_1$, $y_2$, $y_1+y_2$},
extra x ticks={\vx, \ux, \sx}, extra x tick labels={$x_2$, $x_1$, $x_1+x_2$}]
\addplot[-latex] coordinates {(0,0)(\ux,\uy)} node[midway,below]{$\overrightarrow{u}$};
\addplot[-latex] coordinates {(0,0)(\vx,\vy)} node[midway,above]{$\overrightarrow{v}$};
\addplot[dashed] coordinates {(0,\vy)(\vx,\vy)(\vx,0)};
\addplot[dashed] coordinates {(0,\uy)(\ux,\uy)(\ux,0)};
\addplot[-latex] coordinates {(0,0)({\ux+\vx},{\uy+\vy})} node[pos=0.7,above left]{$\overrightarrow{u}+\overrightarrow{v}$};
\addplot[dashed] coordinates {(\ux,\uy)({\ux+\vx},{\uy+\vy})};
\addplot[dashed] coordinates {(\vx,\vy)({\ux+\vx},{\uy+\vy})};
\addplot[dashed] coordinates {(0,{\uy+\vy})({\ux+\vx},{\uy+\vy})({\ux+\vx},0)};
\end{axis}
\end{tikzpicture}
\end{document}

Output

Output

Solution 2: The real problem here is caused by the fact that you demand the axis to be equal. So you can also just remove axis equal, instead of changing the value of xmin.

1
  • My intention with axis equal was to have both axis with the same scale. How do I accomplish that? – geekformoney Dec 30 '17 at 13:40

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.