-3

Hi happy new year to everyone, please I need help to draw this figure on Latex

enter image description here

Torbjørn T.
  • 206,688
HAITHEM
  • 399
  • 13
    You may want to start with reading the TikZ manual – user202729 Jan 01 '22 at 06:23
  • 1
    As you might have noticed people here does not really like questions of the type 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
  • @daleif i did not ask to do the whole work and thanks for the suggestion !! – HAITHEM Jan 01 '22 at 09:29
  • That is how it is seen to the rest of us and why you've gotten negative votes (not me). – daleif Jan 01 '22 at 09:32
  • @daleif o.k my friend bad luck to start the new year with negative votes this is the first time .. i used to ask for suggestion and get response – HAITHEM Jan 01 '22 at 09:36
  • See this one: https://tex.stackexchange.com/questions/593419/how-can-i-draw-a-graph-that-looks-like-this-hand-drawn-picture as a starting point to create a minimal example. – CarLaTeX Jan 01 '22 at 09:49
  • 3
    Don't take offense about reactions here, but you may get more help if you come with something you already tried and specific questions about parts of your graphic you still struggle with. Feel free to edit your question with a minimal working example (MWE) and we will be happy to help you ;) – SebGlav Jan 01 '22 at 10:15
  • @sebGlav thanks a lot – HAITHEM Jan 01 '22 at 10:49

1 Answers1

4

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}

And the output: enter image description here

Juan Castaño
  • 28,426