tikzpicture箭头从一个图到另一个图

tikzpicture箭头从一个图到另一个图

我是 tikz 的新手,我想做一些类似下图的事情:

[多条曲线绘制至矩阵[1]

我尝试做一些事情,但我不知道如何将矩阵放在图的左侧并在它们之间画一个箭头?

\begin{tikzpicture}[cell/.style={rectangle,draw=black},
space/.style={minimum height=1.5em,matrix of nodes,row sep=-
\pgflinewidth,column sep=-\pgflinewidth,column 1/.style=
{font=\ttfamily}},text depth=0.5ex,text height=2ex,nodes in empty cells]

\matrix (matrice) [
space, 
column 2/.style={minimum width=5em,nodes={cell,minimum width=3.5em}},
column 3/.style={nodes={cell,minimum width=4em}},
 column 4/.style={nodes={cell,minimum width=4em}}]
 {
 $t_1$   &6  & 6  & 7    \\ 
 $t_2$   &3  & 3.5  & 8    \\   
 $t_3$   &4  & 9  & 9    \\ 
 $t_4$   &7  & 9  & 0    \\ };

 \begin{axis}[left= of matrice,
 xlabel=time,
 ylabel=$f(\textrm{temps})$,
 xtick distance=1,
 legend pos=north west
 ,grid=major]
 \addplot  [color=green] table {
 Date GDP  
 1 6
 2 3
 3 4
 4 7
 };
  \addplot [color=blue] table {
 Date X
 1 5
 2 4
 3 5
 4 4
 };
 \addplot [color=red]table {
Date X
1 5.2
2 4.2
3 5.1
4 4.05
 };
\addplot [color=purple]table {
Date X
 1 3.2
 2 4.2
 3 5.19
 4 4.05
 };
 \legend{$sensor 1$, $sensor 2$, $sensor2$}
 \end{axis}
\end{tikzpicture}

我对 tikz 做了什么

回复@Zarko,你的回复对我有帮助,但我仍然对(时间和价值)轴有问题,如下图所示(为什么数字在水平线上方?!):

在此处输入图片描述

新的代码是(事实上我不能使用独立类,因为我使用了书籍类):

       \begin{tikzpicture} 
       \begin{axis}[name=p, legend pos=north west, grid =major, symbolic x            coords={$t_1$,$t_2$,$t_3$,$t_4$,$t_5$,$t_6$,$t_7$,$t_8$,$t_n$}] 
         \addplot+[smooth] coordinates { 
                   ($t_1$,42) 
                   ($t_2$,50) 
                   ($t_3$,80) 
                   ($t_4$,60) 
                   ($t_5$,62) 
                   ($t_n$,90)}; 

         \addplot+[smooth,color=red] coordinates { 
                   ($t_1$,45) 
                   ($t_2$,30) 
                   ($t_3$,70) 
                   ($t_4$,90) 
                   ($t_5$,32) 
                   ($t_n$,50)}; 
                     \addplot+[smooth,color=green] coordinates { 
                   ($t_1$,35) 
                   ($t_2$,20) 
                   ($t_3$,80) 
                   ($t_4$,60) 
                   ($t_5$,22) 
                   ($t_n$,40)};
                   \legend{\emph{capteur} 1, \emph{capteur} 2,\emph{capteur} 3}
           \end{axis} 
       \matrix (matrice) [matrix of math nodes,
                           nodes={draw, font=\ttfamily,
                                  minimum width=4em, text depth=0.5ex, text height=2ex},
                           column sep=-\pgflinewidth, row sep=-\pgflinewidth,
                           right=of p]    {
       & {\color{red}$c_1$} & {\color{blue}$c_2$} &{\color{green}$c_3$}                 \\  
       $t_1$&   6  &    6   &   7   \\
       $t_2$ &   3  &   3   &   8   \\
       $t_3$ &   4  &   9   &   9   \\
                  $t_4$ &   7  &   9   &   0   \\
       $t_5$ &  .  &    .  &    . \\
       $.$ &  .  &    .  &    .  \\
       $.$ &   .  &    .  &    .  \\
       $.$ &   .  &    .  &    .  \\
       $t_n$ &   7  &   9   &   0   \\
       };
       \draw[ultra thick,-Straight Barb, shorten <=1mm, shorten            >=1mm,color=black]
           (p) -- (matrice);    
       \end{tikzpicture} 

序言部分

  ` \documentclass[a4paper,11pt]{book}%,12pt draft twoside
     \def\version{0.5}
     % \def\padding{\input{padding.txt}}
\def\x{\ensuremath{\times}}
\def\bul{\ensuremath{\bullet}}
\def\cir{\ensuremath{\circ}}
%\def\release{v.\version, r.\svnrev}
\usepackage[frenchb]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{aeguill}%défaut [lm]
\usepackage{palatino}
\usepackage{mathpazo}
\linespread{1.02} 
\newcommand{\mc}[3]{\multicolumn{#1}{#2}{#3}}
\newcommand{\mr}[3]{\multirow{#1}{#2}{#3}}
\newcommand{\note}[1]         {\marginpar[\raggedleft\footnotesize\itshape#1\par{\raggedright\footnotesiz\itshape#1\par}}

        \newcommand{\removenotes}{\renewcommand{\note}[1]{}}
         \newcommand{\vertc}[1]{\rotatebox{90}{\textbf{#1}}}
         \newcommand{\vertcr}[1]{\rotatebox{-90}{\textbf{#1}}}
         \newcommand{\vertcn}[1]{\rotatebox{90}{#1}}
         \usepackage{url}
         \usepackage{xspace}
         \usepackage[active]{srcltx}
         \usepackage{moreverb}
         %\usepackage{svn-multi}
        % \svnid{$Id: MainThese.tex 401 2008-05-15 16:59:00Z rthion $}
        \usepackage{datetime}
        \usepackage{amsmath}
        \usepackage{amsthm}
        \usepackage{amssymb}
        \DeclareMathOperator{\precprec}{ \prec\!\prec}
        \DeclareMathOperator{\succsucc}{ \succ\!\succ}
        \theoremstyle{plain}
        \newtheorem{thm}{Théorème}%[thm]
        \newtheorem{prop}{Proposition}%[thm]
        \newtheorem{defni}{Définition}
         \newtheorem{lemma}{Lemme}
        \usepackage[french,vlined,linesnumbered,algoruled,lined,boxed]{algorithm2e}     
         \overfullrule=5pt
         \usepackage[a4paper, hmarginratio=1:1]{geometry}
         \geometry{marginparwidth=3cm}
         \addtolength{\headheight}{2.3pt}
         \parskip=5pt
         \usepackage{graphicx}
         \usepackage{epsfig}
        \usepackage{subfigure}
         \usepackage{wrapfig}
        \usepackage{tabularx,lscape,longtable,booktabs}
        \usepackage{slashbox}
        \usepackage{multirow}
        \renewcommand{\multirowsetup}{\centering}
         \usepackage{rotating}
        \tolerance = 400
        \hyphenpenalty=50
        \hbadness = 1500
        \hfuzz 0pt
        \emergencystretch 1em %\emergencystretch 1.5em
        \clubpenalty=9999
        \widowpenalty=9999
     %  \widowpenalty=10000
        \vfuzz \hfuzz
        \raggedbottom




        \usepackage{lettrine}

        \usepackage[usenames]{color}
        \usepackage[table]{xcolor}


         \definecolor{gris10}{rgb}{0.75,0.75,0.75}
        \definecolor{gris60}{rgb}{0.60,0.60,0.60}
        \definecolor{gris80}{rgb}{0.40,0.40,0.40}               


        \usepackage[usenames,dvipsnames]{pstricks}
        \usepackage{pst-grad} % For gradients
        \usepackage{pst-plot} % For axes


        %\usepackage{algorithm}
         \usepackage{algorithmic} 


         \usepackage[helvetica]{quotchap}
         \makeatletter\def\@seccntformat#1{\protect\makebox[0pt][r]{\csname          the#1\endcsname\hspace{12pt}}}\makeatother

        \usepackage{titlesec}   
        \titleformat{\paragraph}[hang]
            {\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
        \titlespacing*{\paragraph} {0pt}{1ex plus 1ex minus .2ex}{0pt}
        \usepackage{fancyhdr}
        \pagestyle{fancyplain}
         \renewcommand{\chaptermark}[1]{\markboth{Chapitre \thechapter.\ #1}{}}
                \renewcommand{\sectionmark}[1]{\markright{Section \thesection.\ #1}}
        \lhead[\fancyplain{}{\bfseries\thepage}] {\fancyplain{}         {\bfseries\rightmark}}          
        \rhead[\fancyplain{}{\bfseries\leftmark}] {\fancyplain{}{\bfseries\thepage}}

         \cfoot{}

         \let\origdoublepage\cleardoublepage
        \newcommand{\clearemptydoublepage}{%
        \clearpage
        {\pagestyle{empty}\origdoublepage}%
        }
        \let\cleardoublepage\clearemptydoublepage 

        %\usepackage[a4paper,ps2pdf,linktocpage,bookmarksnumbered,pagebackref]{hyperref}
         \usepackage[linktocpage,bookmarksnumbered,pagebackref]{hyperref}

         \usepackage[subfigure]{tocloft}


         \usepackage[section,notlof,notlot,notbib]{tocbibind}
         \setcounter{secnumdepth}{3}

        \setcounter{tocdepth}{2}
            \usepackage{float}



         \floatstyle{ruled}

         \newfloat{floexample}{thpb}{loe}[chapter]
         \floatname{floexample}{Exemple}

     %\newcommand{\listdefinitionsname}{Liste des définitions}
     %\renewcommand{\listtablename}{Liste des tables}


         \newlistof[chapter]{definitions}{def}{\listdefinitionsname}
         \setlength{\cftchapnumwidth}{2em}  
         \setlength{\cftbeforechapskip}{2ex}    %réduit l'espacement
         \setlength{\cftbeforesecskip}{0.5ex}   %réduit l'espacement
         \setlength{\cftdefinitionsindent}{1.5em}
        \setlength{\cftdefinitionsnumwidth}{2.3em}
        \usepackage[french,nohints]{minitoc}%
        \mtcsettitle{minitoc}{Plan du chapitre}
        \mtcsetfeature{minitoc}{after}{\clearpage}
        \mtcsetdepth{minitoc}{2}
        \newenvironment{defn}[1]
        %encapsulation de l'env théorème defni
        {   
             \begin{defni}[#1]
            {
                \refstepcounter{definitions}
            }
            {
                \addcontentsline{def}{definitions}                  {\protect\numberline{\thedefinitions}{#1}}
            }  
        }
        {
            \end{defni}     
        }   

        \newenvironment{exemple}[1]
        %def de l'environnement "exemple" qui encadre la description d'un exemple et numérote par chapitre
{           \begin{floexample}
            \begin{center}
            \begin{minipage}{.9\textwidth}
            \caption{\sffamily #1} \sffamily \small \medskip    
        }%à l'ouverture \begin
        {   \end{minipage}
            \end{center}    
            \end{floexample}
        }%à la fermeture \end

     \newenvironment{myQuote}
        {   \begin{quote} %         \hspace{-5pt}
            \itshape        
        }%à l'ouverture \begin
        {
            \end{quote}%\par                
        }%à la fermeture \end


     \newenvironment{resume}
        {   %\textsc{Résumé}
     %      \itshape \small
            \vfill \itshape \small %\sffamily
            $\vartriangleright$}
        {   $\vartriangleleft$ \par \vfill
            \clearpage
                    \minitoc}
     %------------------------------------------------------------------------------------


     % Infos spécifiques aux pdfs
     %----------------------------------------------------------------------         --------------
            \hypersetup{
            pdfauthor   = {},%
            pdftitle    = {},%
            pdfsubject  = {},%
            pdfkeywords = {},%
    }   




         \usepackage{pgfplots} 
         \pgfplotsset{compat=1.15}
         \usepackage{tikz}
         \usetikzlibrary{arrows.meta}
         \usetikzlibrary{matrix,shapes,arrows,fit}
         \usetikzlibrary{shapes.geometric}
         \usetikzlibrary{shapes.misc}
         \usetikzlibrary{matrix,shapes,arrows,fit,tikzmark}
         \usepackage{verbatim}
         \usetikzlibrary{graphs,graphs.standard}
         \usepackage{tabularx}
          \newcolumntype{L}{>{\raggedright\arraybackslash}X}

         % définition des styles
         \tikzstyle{lien}=[->,>=stealth]
         \tikzset{individu/.style={#1!100},individu/.default={black}}





         \tikzset{   
                every picture/.style={remember picture,baseline},
                every node/.style={anchor=base,align=center,outer sep=1.5pt},
                          every path/.style={thick},
               }

         \newcommand\marktopleft[1]{%
           \tikz[overlay,remember picture] 
                 \node (marker-#1-a) at (.1em,.3em) {};%
         }
         \newcommand\markbottomright[1]{%
            \tikz[overlay,remember picture] 
                \node (marker-#1-b) at (.1em,.3em) {};%
            \tikz[overlay,remember picture,inner sep=5pt]
               \node[draw=red,rounded corners,fit=(marker-#1-a) (marker-#1-b)] {};%
         }




         \usetikzlibrary{positioning}
         \tikzset{main node/.style={circle,fill=blue!20,draw,minimum             size=1cm,inner sep=0pt},
                     }



         \let\clipbox\relax
         \usepackage{adjustbox}
         \usepackage{rotating}


         \DeclareMathOperator{\e}{e}
         \DeclareMathOperator*{\argminA}{arg\,min} 
         \DeclareMathOperator*{\argminB}{argmin} 
         \DeclareMathOperator{\E}{\mathbb{E}}
         %\usepackage{algpseudocode}
         \newtheorem{theorem}{Theorem}

         \newcommand{\listtheoremname}{Liste des Théorèmes}

         \newcommand\numberthis{\addtocounter{equation}          {1}\tag{\theequation}}
         \usepackage{pifont}
         \newcommand{\cmark}{\ding{51}}%
         \newcommand{\xmark}{\ding{55}}%
         %\newtheorem{lemma}{lemme} 
         %\usepackage{ams}
         \def\T{\rm T}
         \def\M{\rm M}
         \def\R{\rm R}
         \def\RR{\mathbb R}
         \def\D{\rm D}
         \def\L{\rm L}
         \def\I{\rm I}
         \def\W{\rm W}
         \usepackage{bm}
         \usepackage{bibentry}
         \usepackage{epstopdf}
         \usepackage{pdfpages}






         \providecommand{\keys}[1]{\textbf{\textit{Keywords---}} #1}


         \usepackage{pgfplots,pgfplotstable}
         \usepgfplotslibrary{dateplot}
         \usepackage{pgfplots}
         \pgfplotsset{compat=1.15}
         \pgfplotsset{xticklabel={\tick},scaled x ticks=false}
         \pgfplotsset{plot coordinates/math parser=false}
         \usetikzlibrary{arrows.meta, matrix, positioning}

`

答案1

编辑(1)

同时我发现我们可以给图表命名并将所有图像绘制为一幅图:

编辑(2)

  • 被视为表格,如您编辑的答案中所示
  • 请使用中的代码,pgfplots就像matrix我的答案中一样。你的修改会引入错误

在此处输入图片描述

就这三幅图而言:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{arrows.meta, matrix, positioning}

\begin{document}
    \begin{tikzpicture}[node distance=22mm]
\begin{axis}[
name=p,
    xlabel = time,
    ylabel =$ f(\textrm{temps})$,
    xtick distance=1,
    grid=major]
\addplot table {Date GDP
                 1 6
                 2 3
                 3 4
                 4 7
                 };
\addplot table {Date X
                 1 5
                 2 4
                 3 5
                 4 4
                 };
\addplot table {Date X
                1 5.2
                2 4.2
                3 5.1
                4 4.05
                 };
\addplot table {Date X
                 1 3.2
                 2 4.2
                 3 5.19
                 4 4.05
                 };
\legend{\emph{sensor} 1, \emph{sensor} 2, \emph{sensor} 3,\emph{sensor} 4}
\end{axis}
\matrix (matrice)  [matrix of math nodes,
                    nodes={draw, font=\ttfamily,
                           minimum width=3em, text depth=0.4ex, text height=1.75ex},
                    column sep=-\pgflinewidth, row sep=-\pgflinewidth,
                    right=of p]    {
t_1 &   6  &    6   &   7   \\
t_2 &   3  &    3.5 &   8   \\
t_3 &   4  &    9   &   9   \\
t_4 &   7  &    9   &   0   \\
};
\draw[ultra thick,-Straight Barb, shorten <=2mm, shorten >=2mm]
    (p) -- (matrice);
    \end{tikzpicture}
\end{document}

相关内容