Hi happy new year to everyone, please I need help to draw this figure on Latex
- 206,688
- 399
1 Answers
You can do something like the following. I created a couple of styles to allow easy visual modifications, and then I made a scope with a change of origin and a rotation. The new origin will be at the cross point of the gray/green lines, and the x-axis will be the same than the green line. This way it will be simple to find the coordinates of all elements involved.
The code:
\documentclass[tikz,border=2mm]{standalone}
\tikzset
{% styles
dot/.style={circle,draw,fill=#1,inner sep=0,minimum size=0.3cm},
for text/.style={black,text width=2.4cm,align=center,font=\footnotesize},
double arrow/.style={<->,rounded corners},
margem/.style={latex-latex,thick,magenta!70!black},
otima/.style={green!50!black,very thick}
}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
% axes
\draw[-latex] (-1,0) -- (10,0) node[below] {$x_1$};
\draw[-latex] (0,-1) -- (0,8) node[left] {$x_2$};
% red dots
\foreach\i/\j in {5/2,6/2.5,6/1.5,7.1/1,7/2,6.9/3,7.9/2.5,8/1.5}
\node[dot=red] at (\i,\j) {};
% blue dots
\foreach\i/\j in {2/4.8,3/5,2.5/5.8,3.5/6,4.5/6,5.5/6.5,4.5/7}
\node[dot=blue] at (\i,\j) {};
% here I change the origin and rotate all around it
\begin{scope}[shift={(5,4)},rotate=30]
% gray lines
\foreach\i in {-40,-20,40}
\draw[thick,gray!50] (\i:-4) -- (\i:4);
% hiperplano de separação ótima
\draw[otima] (-5,0) -- (5,0);
% hiperplanos
\foreach\i in {-1,1}
\draw[dashed] (-5,\i) -- (5,\i);
% some more dots
\node[dot=red] at (0,-1) {};
\foreach\i in {-1,1}
\node[dot=blue] at (0.7*\i,1) {};
% labels
\draw[double arrow] (-0.7,1.25) |-++ (1.4,0.5) -- (0.7,1.25);
\draw[double arrow] (5.1,-1) -|++ (0.5,2) -- (5.1,1);
\draw (5.6,0) --++ (1.5,0) node[right,for text] {Hiperplanos de Suporte};
\draw (0,1.75) --++ (0,1.5) node[above,for text] {Vetores de Suporte};
\draw[margem] (-3.5,1) --++ (0,-2) node[below,for text] {Margem de separação};
\draw[<-] (4,-0.1) --++ (0,-3) node[below,for text] {Hiperplano de Separação Ótima};
\draw[<-] (0,-1) + (230:0.25) --++ (230:2) node[below,for text] {Vetor de Suporte};
\end{scope}
\end{tikzpicture}
\end{document}
- 28,426
-
1Castano i' am so very grateful for your time, thank you so much for your assistance – HAITHEM Jan 01 '22 at 15:01


please do this for me. As already mentioned, start looking into tikz. This image is not super hard to do in tikz, just takes time – daleif Jan 01 '22 at 09:16