I'm trying to edit a 2D figure using Tikz. My current code and plot are as follow:
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}`
\begin{document}
\begin{figure}[hbt]
\centering
\begin{tikzpicture}[scale=350]
\centering
\draw[blue,thick] (0,0) -- (0.0219837,0)-- (0.0219837,0.0168148)-- (0.0056579,0.0168148) -- (0.0052959,0.0127) -- (0.0027051,0.0127) -- (0.0027051,0.0142494)--(0,0.0142494) -- cycle;
%\filldraw[fill=green!20,draw=green!50!black]
\draw[line width=1mm, red] (0.0024, 0.0142495) -- (0.0024, 0.01225);
\draw[line width=1mm, green] (0.0024, 0.0122495) -- (0.0024, 0.002);
\draw[line width=1mm, black] (0.0024, 0.002, 0.0) -- (0.0024, 0.0);
\draw[line width=0.55mm, magenta] (0.0, 4.0E-8) -- (0.0219837, 4.0E-8);
\end{tikzpicture}
\caption{2D domain.}
\label{fig:2D Domain}
\end{figure}
\end {document}
This provides me the following figure:
Now, I'd like to edit my figure as follow: i.e. each of the newly added lines (3 Vertical, 1 horizontal) should have the legends with respective colors as indicated in the figure. For example, I have used, red, green, blue, and magenta. Also, I want them to be aligned.
Best Answer
Just draw the lines at the desired positions and add a node at their end. For example:
I don't know if you need to preserve the line widths, if this is not the case remove them.
This could be the complete code: