# Position of y axis with pgfplots

I am currently trying to create a plot with pgfplots and can't seem to properly position the y axis like I want to. Here's my MWE:

\documentclass{standalone}

\usepackage{pgfplots}

\pgfdeclareplotmark{ball}{%
}

\usetikzlibrary{decorations.markings}
\tikzset{
set arrow inside/.code={\pgfqkeys{/tikz/arrow inside}{#1}},
set arrow inside={end/.initial=>, opt/.initial=},
/pgf/decoration/Mark/.style={
mark/.expanded=at position #1 with
{
\noexpand\arrow[\pgfkeysvalueof{/tikz/arrow inside/opt}]{\pgfkeysvalueof{/tikz/arrow inside/end}}
}
},
arrow inside/.style 2 args={
set arrow inside={#1},
postaction={
decorate,decoration={
markings,Mark/.list={#2}
}
}
},
}

\begin{document}

\def\length{sqrt(4*x^2+(x-y)^2)}

\begin{tikzpicture}

\begin{axis}[%
axis lines=left,
grid=minor,
height=8cm,
width=15cm,
domain=-1:1,
view={30}{70},
xlabel={$s$},
ylabel={$\overline{s}$},
zlabel={$e$},
xmin=-1,
xmax=1,
yticklabels={\empty},
zticklabels={\empty},
extra x ticks={-1,0,1},
extra y ticks={-1,0,1},
extra z ticks={0.05,0.1},
ymin=-1,
ymax=1,
zmin=0,
zmax=0.1,
restrict x to domain = -1:1,
restrict y to domain = -1:1,
axis line style = {-latex},
every axis x label/.style={
at={(ticklabel* cs:1)},
anchor=north
},
every axis y label/.style={
at={(ticklabel* cs:1)},
anchor=south,
},
every axis z label/.style={
at={(ticklabel* cs:1)},
anchor=south,
}
]

table[row sep=crcr] {%
x   y   z\\
0   0   0\\
1   0   0\\
1   1   0\\
0   1   0\\
}--cycle;

\addplot3[red, quiver={u={-2*x/(\length)}, v={(x-y)/(\length)}, scale arrows=0.075}, -stealth,samples=20] {0};

\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:-1,1,0) -- (axis cs:0,0,0);
\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:1,-1,0) -- (axis cs:0,0,0);
\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:0,1,0) -- (axis cs:0,0,0);
\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:0,-1,0) -- (axis cs:0,0,0);

\addplot3[color = blue, mark = *,fill=blue, mark size=2pt] coordinates {(0,0,0)};\\

\end{axis}
\end{tikzpicture}

\end{document}


This gives me the following output.

My problem now is now that the y axis is on the right instead of left. What I would like (and seem to be unable to achieve) is for all three axis to intersect in the same point. Could somebody help?

PS: Just now I noticed that the grey dots of the grid overlay the x and y axis... How do I get rid of that?

### Edit:

Stefan Pinnow: No, the intersection point shouldn't be the origin, but rather where the x and z axis already intersect (which is (-1,-1,0)).

I replaced axis lines=left with axis x line=left, axis y line=right, axis z line=left, which produces the following.

This is almost what I want, only I'd like to have the y axis on the bottom. Is it possible to a apply a zshift to the y axis? If so, how?

• If "the same point" is the origin, just replace axis lines=left with axis lines=center. – Stefan Pinnow Jan 17 '16 at 8:34
• @StefanPinnow The OP replied to your comment in an answer that was deleted, I edited the question to include that info. – Torbjørn T. Feb 24 '17 at 17:26

Ugly workaround, but you could draw that axis manually. Set axis y line=none, and add

\draw [-latex]
(\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymin},\pgfkeysvalueof{/pgfplots/zmin}) --
(\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax},\pgfkeysvalueof{/pgfplots/zmin})
node[above]{$\overline{s}$};


in the axis environment.

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}

\pgfdeclareplotmark{ball}{%
}

\usetikzlibrary{decorations.markings}
\tikzset{
set arrow inside/.code={\pgfqkeys{/tikz/arrow inside}{#1}},
set arrow inside={end/.initial=>, opt/.initial=},
/pgf/decoration/Mark/.style={
mark/.expanded=at position #1 with
{
\noexpand\arrow[\pgfkeysvalueof{/tikz/arrow inside/opt}]{\pgfkeysvalueof{/tikz/arrow inside/end}}
}
},
arrow inside/.style 2 args={
set arrow inside={#1},
postaction={
decorate,decoration={
markings,Mark/.list={#2}
}
}
},
}

\begin{document}

\def\length{sqrt(4*x^2+(x-y)^2)}

\begin{tikzpicture}

\begin{axis}[%
axis x line=left, axis y line=none, axis z line=left,
grid=minor,
height=8cm,
width=15cm,
domain=-1:1,
view={30}{70},
xlabel={$s$},
ylabel={$\overline{s}$},
zlabel={$e$},
xmin=-1,
xmax=1,
yticklabels={\empty},
zticklabels={\empty},
extra x ticks={-1,0,1},
extra y ticks={-1,0,1},
extra z ticks={0.05,0.1},
ymin=-1,
ymax=1,
zmin=0,
zmax=0.1,
restrict x to domain = -1:1,
restrict y to domain = -1:1,
axis line style = {-latex},
every axis x label/.style={
at={(ticklabel* cs:1)},
anchor=north
},
every axis y label/.style={
at={(ticklabel* cs:1)},
anchor=south,
},
every axis z label/.style={
at={(ticklabel* cs:1)},
anchor=south,
}
]

\draw [-latex]
(\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymin},\pgfkeysvalueof{/pgfplots/zmin}) --
(\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax},\pgfkeysvalueof{/pgfplots/zmin})
node[above]{$\overline{s}$};

table[row sep=crcr] {%
x   y   z\\
0   0   0\\
1   0   0\\
1   1   0\\
0   1   0\\
}--cycle;

\addplot3[red, quiver={u={-2*x/(\length)}, v={(x-y)/(\length)}, scale arrows=0.075}, -stealth,samples=10] {0};

\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:-1,1,0) -- (axis cs:0,0,0);
\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:1,-1,0) -- (axis cs:0,0,0);
\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:0,1,0) -- (axis cs:0,0,0);
\draw[blue,arrow inside={end=stealth,opt={scale=1}}{0.2,0.4,0.6,0.8}] (axis cs:0,-1,0) -- (axis cs:0,0,0);

\addplot3[color = blue, mark = *,fill=blue, mark size=2pt] coordinates {(0,0,0)};\\

\end{axis}
\end{tikzpicture}

\end{document}