0

I am trying to draw a graph where I need emphasize a partition with dashed, line in the picture below. May someone help me how can I do this?

sample

1
  • Please post a MWE of what you have tried so far. If you don't know where to start, you can look at the TikZ package, there are some tutorials at the beginning of the manual to get you started. – KersouMan Jun 27 '20 at 8:40
2

You could to use Geogebra to export your drawing in TikZ or you can use easily Mathcha as this example to use with a lot of patience and attenction.

%% Compile and read me!
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\begin{document}
\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300

%Shape: Circle [id:dp7927248797566291] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (144,110.5) .. controls (144,108.01) and (146.01,106) .. (148.5,106) .. controls (150.99,106) and (153,108.01) .. (153,110.5) .. controls (153,112.99) and (150.99,115) .. (148.5,115) .. controls (146.01,115) and (144,112.99) .. (144,110.5) -- cycle ;
%Shape: Circle [id:dp682370555115277] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (166,60.5) .. controls (166,58.01) and (168.01,56) .. (170.5,56) .. controls (172.99,56) and (175,58.01) .. (175,60.5) .. controls (175,62.99) and (172.99,65) .. (170.5,65) .. controls (168.01,65) and (166,62.99) .. (166,60.5) -- cycle ;
%Shape: Circle [id:dp03201160866261832] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (336,60.5) .. controls (336,58.01) and (338.01,56) .. (340.5,56) .. controls (342.99,56) and (345,58.01) .. (345,60.5) .. controls (345,62.99) and (342.99,65) .. (340.5,65) .. controls (338.01,65) and (336,62.99) .. (336,60.5) -- cycle ;
%Shape: Circle [id:dp9854929240988808] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (355,110.5) .. controls (355,108.01) and (357.01,106) .. (359.5,106) .. controls (361.99,106) and (364,108.01) .. (364,110.5) .. controls (364,112.99) and (361.99,115) .. (359.5,115) .. controls (357.01,115) and (355,112.99) .. (355,110.5) -- cycle ;
%Straight Lines [id:da11166524774941577] 
\draw    (170.5,60.5) -- (337.5,60.5) ;
%Shape: Circle [id:dp8943585411870774] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (216,190.5) .. controls (216,188.01) and (218.01,186) .. (220.5,186) .. controls (222.99,186) and (225,188.01) .. (225,190.5) .. controls (225,192.99) and (222.99,195) .. (220.5,195) .. controls (218.01,195) and (216,192.99) .. (216,190.5) -- cycle ;
%Shape: Circle [id:dp6681469354354261] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (283,190.5) .. controls (283,188.01) and (285.01,186) .. (287.5,186) .. controls (289.99,186) and (292,188.01) .. (292,190.5) .. controls (292,192.99) and (289.99,195) .. (287.5,195) .. controls (285.01,195) and (283,192.99) .. (283,190.5) -- cycle ;
%Straight Lines [id:da8629800216297543] 
\draw    (148.5,110.5) -- (359.5,110.5) ;
%Straight Lines [id:da6313996768798253] 
\draw    (359.5,110.5) -- (287.5,190.5) ;
%Straight Lines [id:da7883856995250305] 
\draw    (340.5,60.5) -- (220.5,190.5) ;
%Straight Lines [id:da4476925836739323] 
\draw    (170.5,60.5) -- (287.5,190.5) ;
%Straight Lines [id:da5855974142654277] 
\draw    (148.5,110.5) -- (220.5,190.5) ;
%Shape: Ellipse [id:dp581159951498766] 
\draw  [dash pattern={on 4.5pt off 4.5pt}] (175.99,44.95) .. controls (186.29,48.96) and (187.53,70.42) .. (178.77,92.88) .. controls (170.02,115.34) and (154.58,130.29) .. (144.29,126.28) .. controls (134,122.26) and (132.75,100.81) .. (141.51,78.35) .. controls (150.26,55.89) and (165.7,40.94) .. (175.99,44.95) -- cycle ;
%Shape: Ellipse [id:dp7393747619154876] 
\draw  [dash pattern={on 4.5pt off 4.5pt}] (338.89,43.28) .. controls (327.78,46.26) and (323.83,67.55) .. (330.06,90.83) .. controls (336.29,114.11) and (350.36,130.58) .. (361.47,127.6) .. controls (372.58,124.63) and (376.53,103.34) .. (370.3,80.06) .. controls (364.06,56.77) and (350,40.31) .. (338.89,43.28) -- cycle ;
%Shape: Ellipse [id:dp4121965153815268] 
\draw  [dash pattern={on 4.5pt off 4.5pt}] (297.78,189.08) .. controls (297.66,200.12) and (278.03,208.87) .. (253.93,208.61) .. controls (229.82,208.35) and (210.38,199.19) .. (210.5,188.15) .. controls (210.62,177.1) and (230.25,168.36) .. (254.35,168.61) .. controls (278.46,168.87) and (297.9,178.03) .. (297.78,189.08) -- cycle ;

% Text Node
\draw (155,63.07) node [anchor=north west][inner sep=0.75pt]    {$A$};
% Text Node
\draw (149,91.07) node [anchor=north west][inner sep=0.75pt]    {$B$};
% Text Node
\draw (338,63.9) node [anchor=north west][inner sep=0.75pt]    {$C$};
% Text Node
\draw (352.18,89.5) node [anchor=north west][inner sep=0.75pt]    {$D$};
% Text Node
\draw (227,183.07) node [anchor=north west][inner sep=0.75pt]    {$E$};
% Text Node
\draw (266,183.07) node [anchor=north west][inner sep=0.75pt]    {$F$};


\end{tikzpicture}


\end{document}

enter image description here

2

You can achieve the desired result easily with TikZ. What I propose is not optimal but gets you to the desired result. It is based on the answer found here which provides a macro \ellipsebyfoci for drawing an ellipse by specifying its two foci. You need to specify the drawing options as the first argument, the foci as second and third arguments, and the eccentricity as fourth argument.

The example code:

\documentclass{standalone}

\usepackage{tikz}
    \usetikzlibrary{calc}

\newcommand\ellipsebyfoci[4]{% options, focus pt1, focus pt2, cste
    \path[#1] let \p1=(#2), \p2=(#3), \p3=($(\p1)!.5!(\p2)$)
    in \pgfextra{
        \pgfmathsetmacro{\angle}{atan2(\y2-\y1,\x2-\x1)}
        \pgfmathsetmacro{\focal}{veclen(\x2-\x1,\y2-\y1)/2/1cm}
        \pgfmathsetmacro{\lentotcm}{\focal*2*#4}
        \pgfmathsetmacro{\axeone}{(\lentotcm - 2 * \focal)/2+\focal}
        \pgfmathsetmacro{\axetwo}{sqrt((\lentotcm/2)*(\lentotcm/2)-\focal*\focal}
    }
    (\p3) ellipse[x radius=\axeone cm,y radius=\axetwo cm, rotate=\angle];
}

\begin{document}
    
    \begin{tikzpicture}
    
        \coordinate (a) at (-4.5, 1);
        \coordinate (b) at (-3.5, 3);
        \coordinate (c) at (3.5, 3);
        \coordinate (d) at (4.5, 1);
        \coordinate (e) at (-1.5, -3);
        \coordinate (f) at (1.5, -3);
        
        \draw (a) -- (d) -- (f) -- (b) -- (c) -- (e) -- cycle;
        
        \foreach \x/\y/\z in {a/above left/A,b/above left/B,c/above right/C,d/above right/D,e/below/E,f/below/F}{
            \fill[blue] (\x) circle (0.1);
            \node[blue, \y] at (\x) {\z};
        }
            
        \ellipsebyfoci{draw, dashed}{a}{b}{1.5}
        \ellipsebyfoci{draw, dashed}{c}{d}{1.5}
        \ellipsebyfoci{draw, dashed}{e}{f}{1.3}
    
    \end{tikzpicture}
    
\end{document}

yields:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.