标题内的 tikz/gnuplot 图例

标题内的 tikz/gnuplot 图例

我想在标题中添加图例,类似于问题。但我想使用 gnuplot 环境,如以下 MWE 中所示。不幸的是,我得到了“??”,因为\label{test}它不起作用。是否可以使用“gnuplot”环境来做到这一点?或者由 @pluton 提供,这是唯一的方法吗?

我正在从事的 MWE 工作:

\documentclass[12pt,a4paper,english]{article}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{gnuplot-lua-tikz}
\usepackage[shell]{gnuplottex}

\begin{document} 
  \begin{figure}[!ht]
    \centering
    \captionsetup{width=9.5cm}
    \begin{tikzpicture}
      \draw [draw=none,use as bounding box] (0cm,0cm) rectangle (14cm,8cm);{
        \begin{gnuplot}[terminal=tikz,terminaloptions={size 14cm, 8cm}] 
             plot sin(x) w lines t 'sin(x)',\
                  cos(x) w lines t 'cos(x)'
          \label{test}  %gives '??' on the pdf, not working
        \end{gnuplot}
      };
      %\addlegendentry{Legend for only desired lines} % Did not work
      \node[draw=none, text width=1cm] at (-5.0,1.0) {$sin(x)$}; %this has no sample
    \end{tikzpicture}
    \caption[Caption in ToC]{This is a plot about colored curves: \ref{test}}
  \end{figure}   
\end{document}

感谢您的评论,我得到了我想要的。

血管内皮生长因子(创造了一个传奇\caption

\documentclass[12pt,a4paper,english]{article}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{gnuplot-lua-tikz}
\usepackage[shell]{gnuplottex}

\begin{document} 
\begin{figure}[!ht]
  \centering
  \captionsetup{width=9.5cm}
    \begin{tikzpicture}
      \draw [draw=none,use as bounding box] (0cm,0cm) rectangle (14cm,8cm);{
        \begin{gnuplot}[terminal=tikz,terminaloptions={size 14cm, 8cm}] 
           set style line 1  lc rgb "black"  lt 1 lw 1 pointinterval 1 pt 1
           set style line 11 lc rgb "black"  lt 1 lw 5 pointinterval 5 pt 12
           plot sin(x) w lines ls 1 t 'sin(x)',\
                cos(x) w lines ls 11 t 'cos(x)'
        \end{gnuplot}
      };
      \node[draw=none, text width=1cm] at (-5.0,1.0) {$sin(x)$}; %this has no sample
    \end{tikzpicture}
    \caption[Caption in ToC]{
      \begin{tikzpicture}[baseline=-.5ex,line join=round,line cap=round,color=black]
      %First legend
      \pgfsetlinewidth{1\gpbaselw}
      \node[draw=none, text width=1cm] at (0.0,0.0) {$sin(x)$}; %this has no sample
      \draw (0.75,0) -- (1.10,0); 
      %Creat following legend
      \pgfsetlinewidth{5\gpbaselw}
      \node[draw=none, text width=1cm] at (1.8,0.0) {$cos(x)$}; %this has no sample
      \draw (2.5,0) -- (2.85,0);
      \end{tikzpicture}
    }
  \end{figure}   
\end{document}

工作目标 在此处输入图片描述

相关内容