0

I am new to tikz just able to draw some arrows but going to complex part unable to find the location and technique to do so.

\documentclass[xcolor=dvipsnames, aspectratio=169, 11pt]{beamer}
\usepackage{beamerthemeshadow}
\usepackage[absolute,overlay]{textpos}
\begin{document}
\section{}
\begin{frame}
    \frametitle{Matplotlib}
    \framesubtitle{Input}
    \scriptsize
    \begin{columns}[T] % align columns
    \begin{column}{0.5\textwidth}
        \color{Black}
        \begin{block}{Array}
        \texttt{%
         ax.tick\_params(which=`major', width=1.0)\\
        ax.tick\_params(which=`major', length=10)\\
        ax.tick\_params(which=`minor', width=1.0, labelsize=10)\\
        ax.tick\_params(which=`minor', length=5, labelsize=10, labelcolor=`0.25')\\  
        ax.grid(linestyle="--", linewidth=0.5, color=`.25', zorder=-10)\\  
        ax.plot(X, Y1, c=(0.25, 0.25, 1.00), lw=2, label="Blue signal", zorder=10)\\
        ax.plot(X, Y2, c=(1.00, 0.25, 0.25), lw=2, label="Red signal")\\
        ax.plot(X, Y3, linewidth=0,marker=`o', markerfacecolor=`w', markeredgecolor=`k')\\  
        ax.set\_title("Anatomy of a figure", fontsize=20, verticalalignment=`bottom')\\
        ax.set\_xlabel("X axis label")\\
        ax.set\_ylabel("Y axis label")\\  
        ax.legend()\\   }\\
        \end{block}
        
    \end{column}%
    \hfill%
    \begin{column}{.5\textwidth}
    
    \end{column}%
\end{columns}

\end{frame}
\end{document}

so much of stuff in a single slide looks complicated for beginner like me

6
  • 1
    Sorry but I don't understand the link between your code and the picture you provided below it. What do you exactly try to do, and what did you do yet?
    – SebGlav
    Jul 24, 2021 at 11:50
  • The code belongs to a slide where I want to point out few places and want to describe them as given in the picture using tikz.
    – avi007
    Jul 24, 2021 at 12:19
  • Now that you edited it, it's much clearer. Do you know about tikzmark library? This would be a nice way to achieve this.
    – SebGlav
    Jul 24, 2021 at 12:28
  • This answer uses an old version of tikzmark. Better lead to one using the actual library, I think.
    – SebGlav
    Jul 24, 2021 at 12:43

1 Answer 1

3

Here's something you can start with:

tikzmark in beamer

\documentclass[xcolor=dvipsnames, aspectratio=169, 11pt]{beamer}
\usepackage{beamerthemeshadow}
\usepackage[absolute,overlay]{textpos}
\usepackage{tikz} \usetikzlibrary{tikzmark,calc}

\begin{document}
\section{}
\begin{frame}
    \frametitle{Matplotlib}
    \framesubtitle{Input}
    \scriptsize
    \begin{columns}[T] % align columns
    \begin{column}{0.5\textwidth}
        \color{Black}
        \begin{block}{Array}
        \texttt{%
         \tikzmarknode{o}{}ax.tick\_params(\tikzmarknode{A}{which='major'}, width=1.0)\\
        ax.tick\_params(which='major', length=10)\\
        ax.tick\_params(which='minor', width=1.0, labelsize=10)\\
        ax.tick\_params(which='minor', \tikzmarknode{B}{length=5}, labelsize=10, labelcolor='0.25')\\  
        ax.grid(linestyle="--", linewidth=0.5, color='.25', zorder=-10)\\  
        ax.plot(X, Y1, c=(0.25, 0.25, 1.00), lw=2, label="Blue signal", zorder=10)\\
        ax.plot(X, Y2, c=(1.00, 0.25, 0.25), lw=2, label="Red signal")\\
        ax.plot(X, Y3, linewidth=0,\tikzmarknode{C}{marker='o'}, markerfacecolor='w', markeredgecolor=\tikzmarknode{D}{'k'})\\  
        ax.set\_title("Anatomy of a figure", fontsize=20, verticalalignment='bottom')\\
        ax.set\_xlabel("X axis label")\\
        ax.set\_ylabel("Y axis label")\\  
        ax.legend()\\   }
        \end{block}
    \end{column}%
    \hfill%
    \begin{column}{.5\textwidth}
    
    
    \end{column}%
\end{columns}

    \begin{tikzpicture}[remember picture,overlay,
            myline/.style={red,opacity=0.5,very thick},
            myblock/.style={draw,red,minimum height=1cm,minimum width=3cm}]
        \path (o) --++ (10,0) coordinate (O);
        \draw[->,myline] (A.south) to[out=-50,in=180,looseness=.5] (O) node[right,myblock] {First comment};
        \draw[->,myline] (B.south) to[out=-50,in=180,looseness=.5] ($(O)+(0,-1.5)$) node[right,myblock] {Second comment};
        \draw[->,myline] (C.north east) to[out=50,in=180,looseness=.5] ($(O)+(0,-3)$) node[right,myblock] {Third comment};
        \draw[->,myline] (D.south) to[out=-50,in=180,looseness=.5] ($(O)+(0,-4.5)$) node[right,myblock] {Fourth comment};
    \end{tikzpicture}
\end{frame}
\end{document}
6
  • Still showing some errors
    – avi007
    Jul 25, 2021 at 7:48
  • 1
    I had to modify some minor things in your code to make it compilable, and the one I provided here compiles and produces the image above. It's working and answers the question. Now that you've got a starting point, feel free to adapt it and ask another question if you need improvement.
    – SebGlav
    Jul 25, 2021 at 8:37
  • Yes, Thank so much for the guidance and help
    – avi007
    Jul 25, 2021 at 8:44
  • Package pgf Error: No shape named o is known. \end{frame} ad similarly for A, B, C, D. I am unable to understand it. -@SebGlav
    – avi007
    Jul 25, 2021 at 9:21
  • 1
    Maybe your LaTeX distribution is too old and doesn't contain a proper version of tikzmark library. It compiles finely in Overleaf.
    – SebGlav
    Jul 25, 2021 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .