7

I have a figure that I would like to draw in beamer and tikz. Here is the figure:

enter image description here

I start by doing something, but I am not progressing well. Any help?

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

    \begin{frame}
        \tikz[overlay,remember picture]{\node[circle, fill=black] (s1) at (3.8, -1) {};}
        \tikz[overlay,remember picture]{\node[circle, fill=black] (s2) at (2.8, -1) {};}
        \tikz[overlay,remember picture]{\node[circle, fill=black] (s3) at (1.8, 1) {};}
        \tikz[overlay,remember picture]{\node[] (s4) at (2, 0) {All tasks};}
        \tikz[overlay,remember picture]{\draw[->,ultra thick] (3.2, 0) -- (5.8,0) {};}
    \end{frame}

\end{document} 

enter image description here

  • 2
    First tip: you can use the tikzpicture environment to use multiple draw and node commands instead of using the \tikz macro repeatedly. – Paul Gessler Apr 3 '16 at 22:40
8

I know this is not exactly what you want, but it might at least get you started. I added some resources to the code. Unfortunately, pattern density cannot be modified easily in TikZ. I would create a clipping path and draw a bunch of dots, but that might still look too perfect.

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,positioning,shapes,arrows,backgrounds}
%http://tex.stackexchange.com/questions/54464/hatch-a-rectangle-in-tikz
%http://tex.stackexchange.com/questions/114646/where-is-the-pattern-list-gallery-for-pgfplots
%http://tex.stackexchange.com/questions/52372/should-tikzset-or-tikzstyle-be-used-to-define-tikz-styles
%http://tex.stackexchange.com/questions/16231/node-below-and-left-of-another-node-in-tikz
%http://tex.stackexchange.com/questions/121809/positioning-text-in-tikz-drawings
%http://tex.stackexchange.com/questions/53818/how-to-position-nodes-around-another-node-in-tikz
%http://tex.stackexchange.com/questions/130652/randomized-coordinates-in-tikz
\begin{document}
\tikzset{arrow format/.style={->,ultra thick,shorten >= 0mm, shorten <= 2mm}}
\tikzset{main format/.style={ultra thick, draw=black, ellipse, minimum height=2cm,minimum width=6cm,align=center}}
\tikzset{worker format/.style={pattern=dots, pattern color=black,ultra thick, draw=black, ellipse, minimum height=2cm,minimum width=3cm,align=center}}

\tikzset{text format/.style={fill=white,align=center,text width=2cm}}

\begin{tikzpicture}[overlay,remember picture]
\foreach \x in {1,2,...,15}{
    \draw [fill=black] (rand*2.3,rand*1) circle (1mm); }
\node [main format] (main) {} node [text format] {All tasks to be partitioned.};
\node [worker format] (worker3) at ($ (main.east) + (15:5cm) $) {} node [text format,] at (worker3) {Worker 3};
\node [worker format] (worker6) at ($ (main.east) + (345:5cm) $) {} node [text format] at (worker6){Worker 6};
\node [minimum width=3cm] (co-arrow1) at ($ (worker3)!.5!(worker6) $) {};
\draw [arrow format] (main) -- node [midway,above] {Scheduling} (co-arrow1.west);
\end{tikzpicture}
\end{document}

I was working on something like this for the clipping path. The problem is that normal tikz nodes are paths that can not be clipped, so you have to resort to using low-level pgf nodes.

  %http://tex.stackexchange.com/a/53195/13552
  \begin{scope}
    \pgfset{minimum width=5cm,minimum height=2.5cm}
    \pgfnode{ellipse}{center}{All tasks to be partitioned.}{main}{\pgfusepath{stroke,clip}}   
    \foreach \x in {1,2,...,15}{
    \draw [fill=black] (rand*2.3,rand*1) circle (1mm); }
  \end{scope}
2

I continue trying to do something and I get this. It looks fine but not as good as the original picture. (I could not plot the hand-like circle, etc.)

Here is my code:

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

\begin{frame}
\begin{figure}
    \centering
    \resizebox{1\textwidth}{!}{%
    \begin{tikzpicture}
    \node[] (s1) at (2, -.5) {\textbullet};
    \node[] (s2) at (1, -.5) {\textbullet};
    \node[] (s3) at (.8, 1) {\textbullet};
    \node[] (s4) at (-.2, .81) {\textbullet};
    \node[] (s5) at (-.1, 1.2) {\textbullet};
    \node[] (s6) at (-.5, .4) {\textbullet};
    \node[] (s7) at (-1, 1) {\textbullet};
    \node[] (s8) at (.8, 0) {\textbullet};
    \node[] (s9) at (-1,0) {\textbullet};
    \node[] (s10) at (-1.6, .1) {\textbullet};
    \node[] (s11) at (-1.6, -1) {\textbullet};
    \node[] (s12) at (.6, .1) {\textbullet};
    \node[] (s13) at (-.6, .1) {\textbullet};
    \node[] (s14) at (.3, -1) {All tasks};
    \draw[->,ultra thick] (2.7, 0) -- (6.4,0) {};
    \draw[ultra thick] (0,0) ellipse (2.5cm and 1.8cm);
    \node[] (s15) at (8, 1.5) {\textbullet};
    \node[] (s16) at (7, 1.5) {\textbullet};
    \node[] (s17) at (7.8, 1) {\textbullet};
    \node[] (s18) at (6.8, .81) {\textbullet};
    \draw[ultra thick] (7.4,1.2) circle (1cm);
    \node[] (s19) at (8, -1.2) {\textbullet};
    \node[] (s20) at (8.5, -3) {\textbullet};
    \node[] (s21) at (7, -1.8) {\textbullet};
    \node[] (s22) at (8.8, -2) {\textbullet};
    \node[] (s23) at (9,-2) {\textbullet};
    \node[] (s24) at (7.8,-2.5) {\textbullet};
    \node[] (s25) at (8,-1.9) {\textbullet};
    \draw[ultra thick] (8,-2.1) circle (1.3cm);
    \end{tikzpicture}
    }
\end{figure}
\end{frame}

\end{document} 

and here is my output (screenshot):

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.