.tikz 文件:图例与原始 matlab 图形不同

.tikz 文件:图例与原始 matlab 图形不同

.tikz我创建了一个 Matlab 图形。我使用脚本将该图形转换为文件matlab2tikz。但是,我的 - 文件的图例.tikz与 Matlab 图形不同。例如,第二个图例条目指的是 + 标记。在图例中,应该只有 + 号。

但是,出于某种原因,每个图例条目中都有一行额外的线条,这使得所有内容都难以阅读。请参见下图(第二列的第一个条目 - 您几乎无法识别 +)。为什么会出现这些线条?

% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}%
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}%
\definecolor{mycolor4}{rgb}{0.49400,0.18400,0.55600}%
\definecolor{mycolor5}{rgb}{0.46600,0.67400,0.18800}%
\definecolor{mycolor6}{rgb}{0.30100,0.74500,0.93300}%
%
\begin{tikzpicture}

\begin{axis}[%
width=4.0in,
height=2.0in,
at={(0.758in,2.013in)},
scale only axis,
xmin=0,
xmax=55,
xtick={5,10,15,20,25,30,35,40,45,50},
xticklabels={{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}},
xlabel style={font=\color{white!15!black}},
xlabel={cases},
ymin=10,
ymax=60,
ylabel style={font=\color{white!15!black}},
ylabel={power [dBm]},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left,
xmajorgrids,
ymajorgrids,
legend style={at={(0.5,-0.2)}, anchor=north, legend columns=2, legend cell align=left, align=left, draw=white!15!black}
]
\addplot [color=mycolor1, line width=1.0pt, draw=none, mark size=3.0pt, mark=square, mark options={solid, red}]
  table[row sep=crcr]{%
5   50.25\\
10  49.1\\
15  49.41\\
20  47.99\\
25  48.08\\
30  47.88\\
35  47.73\\
40  49.03\\
45  50.1\\
50  51.05\\
};
\addlegendentry{output power 1st}

\addplot [color=mycolor2, line width=1.0pt, draw=none, mark size=3.0pt, mark=+, mark options={solid, blue}]
  table[row sep=crcr]{%
5   48.02\\
10  48.01\\
15  48\\
20  47.94\\
25  48.02\\
30  47.96\\
35  48.03\\
40  48.01\\
45  47.99\\
50  47.96\\
};
\addlegendentry{IMAL output power 1st}

\addplot [color=mycolor3, line width=1.0pt, draw=none, mark size=3.0pt, mark=o, mark options={solid, black}]
  table[row sep=crcr]{%
5   41.947\\
10  44.268\\
15  46.084\\
20  47.385\\
25  48.036\\
30  47.577\\
35  46.571\\
40  45.09\\
45  44.637\\
50  43.57\\
};
\addlegendentry{MVTRAD output power 1st}

\addplot [color=mycolor4, line width=1.0pt, draw=none, mark size=3.0pt, mark=diamond, mark options={solid, red}]
  table[row sep=crcr]{%
5   40.67\\
10  39.74\\
15  39.71\\
20  36.96\\
25  37.54\\
30  37.12\\
35  36.99\\
40  39.74\\
45  40.71\\
50  37.87\\
};
\addlegendentry{IM power left}

\addplot [color=mycolor5, line width=1.0pt, draw=none, mark size=3.0pt, mark=x, mark options={solid, blue}]
  table[row sep=crcr]{%
5   37.3\\
10  37.46\\
15  37.47\\
20  37.49\\
25  37.43\\
30  37.51\\
35  37.38\\
40  37.45\\
45  37.47\\
50  37.61\\
};
\addlegendentry{IMAL IM power left}

\addplot [color=mycolor6, line width=1.0pt, draw=none, mark size=3.0pt, mark=asterisk, mark options={solid, black}]
  table[row sep=crcr]{%
5   12.903\\
10  22.986\\
15  29.028\\
20  33.666\\
25  36.422\\
30  37.281\\
35  37.006\\
40  36.143\\
45  34.935\\
50  33.81\\
};
\addlegendentry{MVTRAD IM power left}

\end{axis}
\end{tikzpicture}%

在此处输入图片描述

答案1

我猜这是 matlab2tikz 的一个问题。

获得所需内容的最简单方法是将选项添加only marks到图例样式中,即更改行

legend style={at={(0.5,-0.2)}, anchor=north, legend columns=2, legend cell align=left, align=left, draw=white!15!black}

legend style={only marks, at={(0.5,-0.2)}, anchor=north, legend columns=2, legend cell align=left, align=left, draw=white!15!black}

Matlab2tikz 似乎使用选项 删除了图线。如果使用draw=none选项而不是in every ,则图例看起来应该如此。only marksdraw=none\addplot [...]

相关内容