# How to add perpendicular symbol at desired location

I am trying to draw perpendicular symbol on point where the perpendicular line from O is meeting the line AB. But I am unable to achieve it. I try via simple draw because I use pgfplots (you can see in MWE, I had tried tkz-euclide but in vain). Kindly help.

MWE:

\documentclass{article}

\usepackage{graphicx}
\usepackage{amsmath}

\usepackage{tkz-euclide} % loads  TikZ and tkz-base
\usetkzobj{angles} % important you want to use angles

\usepackage{pgfplots}
\usetikzlibrary{angles,quotes,calc}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=0, xmax=3,    ymin=0,    ymax=3,
xlabel = {X}, ylabel = {Y},
ytick=\empty,
xtick=\empty,
clip=false,
grid = major, axis lines = middle  ,
axis line style={gray}
]

\def\uu{\large $\hat{u}$};
\def\vu{\large $\hat{v}$};
\def\au{\large $\vec{a}$};
\def\bu{\large $\vec{b}$};
\def\cu{\large $\vec{c}$};
\coordinate (o) at (0,0);
\coordinate (a) at (1, 2);

\coordinate (b) at (2, 0.5);

\coordinate (u) at (0.26, 0.52);
\coordinate (v) at (0.52, 0.13);

\coordinate (i) at (0.5,0);
\coordinate (j) at (0,0.5);

% \draw pic[draw,fill=cyan!30,angle radius=1.6cm,"$\beta$" shift={(9mm,2mm)}] {angle=i--o--u};
% \draw pic[draw,fill=red!30,angle radius=1.2cm,"$\alpha$" shift={(6mm,2mm)}] {angle=i--o--v};
\draw pic[draw,fill=green!30,angle radius=1cm,"$\theta$" shift={(1mm,1mm)}] {angle=b--o--a};

\draw[line width=2pt,blue,-stealth](o)--(a) node[anchor=south west, xshift=-2mm, yshift=-1mm]{A}; % vector a
\draw[line width=2pt,red,-stealth](o)--(b) node[anchor=south west, xshift=-1mm, yshift=-2mm]{B};   % vector b
\draw[line width=2pt,green!60!black,-stealth](a)--(b);   % vector c

\draw[line width=2pt,blue,-stealth](o)--(u) node[anchor=south east, yshift=-2mm]{\uu};
\draw[line width=2pt,red,-stealth](o)--(v) node[anchor=south west, xshift=-2mm]{\vu};

\draw[line width=1.5pt,-stealth](o)--(i) node[below=6mm, anchor=south east]{$\hat{i}$};
\draw[line width=1.5pt,-stealth](o)--(j) node[anchor=south east]{$\hat{j}$};

% perpendicular line
% https://tex.stackexchange.com/questions/19348/how-to-draw-a-line-passing-through-a-point-and-perpendicular-to-another
\draw ($(a)!(o)!(b)$) -- (o);

\node [above] at (0.51, 1.28) {$\vec{a}$};
\node [below] at (1.42, 0.35) {$\vec{b}$};

% BELOW LINES DO NOT ADD SYMBOL AT RIGHT PLACE.
\coordinate (X) at (o |- a);
\draw ($(X)!5pt!(o)$) -| ($(X)!5pt!(a)$);

\end{axis}

% BELOW IS DRAWING AT WRONG PLACE
% \tkzDefPoint(0,0){O}
% \tkzDefPoint(1,2){A}
% \tkzDefPoint(2,0.5){B}
% \tkzDefPointBy[projection=onto B--A](O)  \tkzGetPoint{H};
% \tkzMarkRightAngle[fill=blue!20,size=.5](O,H,B);

\end{tikzpicture}

\end{document}


Output:

Something like this?

\documentclass{article}

\usepackage{amsmath}

\usepackage{pgfplots}
\usetikzlibrary{angles,quotes,calc}
\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=0, xmax=3,    ymin=0,    ymax=3,
xlabel = {X}, ylabel = {Y},
ytick=\empty,
xtick=\empty,
clip=false,
grid = major, axis lines = middle  ,
axis line style={gray}
]

\def\uu{\large $\hat{u}$};
\def\vu{\large $\hat{v}$};
\def\au{\large $\vec{a}$};
\def\bu{\large $\vec{b}$};
\def\cu{\large $\vec{c}$};
\coordinate (o) at (0,0);
\coordinate (a) at (1, 2);

\coordinate (b) at (2, 0.5);

\coordinate (u) at (0.26, 0.52);
\coordinate (v) at (0.52, 0.13);

\coordinate (i) at (0.5,0);
\coordinate (j) at (0,0.5);

% \draw pic[draw,fill=cyan!30,angle radius=1.6cm,"$\beta$" shift={(9mm,2mm)}] {angle=i--o--u};
% \draw pic[draw,fill=red!30,angle radius=1.2cm,"$\alpha$" shift={(6mm,2mm)}] {angle=i--o--v};
\draw pic[draw,fill=green!30,angle radius=1cm,"$\theta$" shift={(1mm,1mm)}] {angle=b--o--a};

\draw[line width=2pt,blue,-stealth](o)--(a) node[anchor=south west, xshift=-2mm, yshift=-1mm]{A}; % vector a
\draw[line width=2pt,red,-stealth](o)--(b) node[anchor=south west, xshift=-1mm, yshift=-2mm]{B};   % vector b
\draw[line width=2pt,green!60!black,-stealth](a)--(b);   % vector c

\draw[line width=2pt,blue,-stealth](o)--(u) node[anchor=south east, yshift=-2mm]{\uu};
\draw[line width=2pt,red,-stealth](o)--(v) node[anchor=south west, xshift=-2mm]{\vu};

\draw[line width=1.5pt,-stealth](o)--(i) node[below=6mm, anchor=south east]{$\hat{i}$};
\draw[line width=1.5pt,-stealth](o)--(j) node[anchor=south east]{$\hat{j}$};

% perpendicular line
% https://tex.stackexchange.com/questions/19348/how-to-draw-a-line-passing-through-a-point-and-perpendicular-to-another
\draw ($(a)!(o)!(b)$) coordinate(aux0)  -- (o);
\draw ($(aux0)!2mm!(b)$) -- ++ ($($(aux0)!2mm!(o)$)-(aux0)$) -- ($(aux0)!2mm!(o)$);

\node [above] at (0.51, 1.28) {$\vec{a}$};
\node [below] at (1.42, 0.35) {$\vec{b}$};

% BELOW LINES DO NOT ADD SYMBOL AT RIGHT PLACE.
\end{axis}

\end{tikzpicture}
\end{document}


• no marmot, I need the perpendicular sign, something like discussed here – Parthiban Rajendran Nov 8 '18 at 14:39
• @PaariVendhan That's even simpler. – user121799 Nov 8 '18 at 14:50

There might be an easier way, but I can't read french.

\documentclass{article}

\usepackage{graphicx}
\usepackage{amsmath}

\usepackage{tkz-euclide} % loads  TikZ and tkz-base
\usetkzobj{angles} % important you want to use angles

\usepackage{pgfplots}
\usetikzlibrary{angles,quotes,calc}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=0, xmax=3,    ymin=0,    ymax=3,
xlabel = {X}, ylabel = {Y},
ytick=\empty,
xtick=\empty,
clip=false,
grid = major, axis lines = middle  ,
axis line style={gray}
]

\def\uu{\large $\hat{u}$};
\def\vu{\large $\hat{v}$};
\def\au{\large $\vec{a}$};
\def\bu{\large $\vec{b}$};
\def\cu{\large $\vec{c}$};
\coordinate (o) at (0,0);
\coordinate (a) at (1, 2);

\coordinate (b) at (2, 0.5);

\coordinate (u) at (0.26, 0.52);
\coordinate (v) at (0.52, 0.13);

\coordinate (i) at (0.5,0);
\coordinate (j) at (0,0.5);

% \draw pic[draw,fill=cyan!30,angle radius=1.6cm,"$\beta$" shift={(9mm,2mm)}] {angle=i--o--u};
% \draw pic[draw,fill=red!30,angle radius=1.2cm,"$\alpha$" shift={(6mm,2mm)}] {angle=i--o--v};
\draw pic[draw,fill=green!30,angle radius=1cm,"$\theta$" shift={(1mm,1mm)}] {angle=b--o--a};

\draw[line width=2pt,blue,-stealth](o)--(a) node[anchor=south west, xshift=-2mm, yshift=-1mm]{A}; % vector a
\draw[line width=2pt,red,-stealth](o)--(b) node[anchor=south west, xshift=-1mm, yshift=-2mm]{B};   % vector b
\draw[line width=2pt,green!60!black,-stealth](a)--(b);   % vector c

\draw[line width=2pt,blue,-stealth](o)--(u) node[anchor=south east, yshift=-2mm]{\uu};
\draw[line width=2pt,red,-stealth](o)--(v) node[anchor=south west, xshift=-2mm]{\vu};

\draw[line width=1.5pt,-stealth](o)--(i) node[below=6mm, anchor=south east]{$\hat{i}$};
\draw[line width=1.5pt,-stealth](o)--(j) node[anchor=south east]{$\hat{j}$};

% perpendicular line
% https://tex.stackexchange.com/questions/19348/how-to-draw-a-line-passing-through-a-point-and-perpendicular-to-another
\coordinate (X) at ($(a)!(o)!(b)$);
\draw (X) -- (o);

\node [above] at (0.51, 1.28) {$\vec{a}$};
\node [below] at (1.42, 0.35) {$\vec{b}$};

\coordinate (Xo) at ($(X)!5pt!(o)$);
\coordinate (Xb) at ($(X)!5pt!(b)$);
\draw (Xo) -- ($(Xo)!5pt!-45:(Xb)$) -- (Xb);

\end{axis}

% BELOW IS DRAWING AT WRONG PLACE
% \tkzDefPoint(0,0){O}
% \tkzDefPoint(1,2){A}
% \tkzDefPoint(2,0.5){B}
% \tkzDefPointBy[projection=onto B--A](O)  \tkzGetPoint{H};
% \tkzMarkRightAngle[fill=blue!20,size=.5](O,H,B);

\end{tikzpicture}

\end{document}