叠加问题以及如何更改图例符号

叠加问题以及如何更改图例符号

给出如下的情节

在此处输入图片描述

我有两个问题:

  1. a 和 b 互相叠加,我应该如何在图上清楚地表示出来?
  2. 我怎样才能将图例 c 更改为其他图标,例如星号?(它看起来有点类似于 a)

代码如下所示:

\documentclass[tikz]{standalone}
\usepackage{pgf}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows,automata,positioning}
\begin{document}
 \begin{tikzpicture}[font=\sffamily]
\begin{semilogyaxis}[title=Random Dataset,
legend pos=outer north east,
legend style={draw=none},
xtick={1,2,...,9}, 
scaled ticks=false,
log ticks with fixed point={1000 sep=},
axis x line=bottom,
axis y line=left,
axis line style=-,
minor tick style={draw=none},
enlargelimits,
ylabel = Solving Time (ms),
xlabel = Number of Constraints,
every axis legend/.append style={xshift=-10pt}
]
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,100)(7,100)(8,100)(9,100)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,100)(7,100)(8,100)(9,100)};
\addplot plot coordinates{(1,78)(2,62)(3,41)(4,44)(5,120)(6,96)(7,133)(8,133)(9,91)};
\legend{a,b,c}
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

答案1

一种方法是更改​​绘图样式,以便可以看到ab标记。例如,使用 的箭头square可以b使a点可见。

对于您的第二个问题,使用\addplot+[mark=triangle]一个足够不同的三角形,这样它就不会与其他标记混淆。

在此处输入图片描述

代码:

\documentclass[tikz]{standalone}
\usepackage{pgf}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows,automata,positioning}
\begin{document}
 \begin{tikzpicture}[font=\sffamily]
\begin{semilogyaxis}[title=Random Dataset,
legend pos=outer north east,
legend style={draw=none},
xtick={1,2,...,9}, 
scaled ticks=false,
log ticks with fixed point={1000 sep=},
axis x line=bottom,
axis y line=left,
axis line style=-,
minor tick style={draw=none},
enlargelimits,
ylabel = Solving Time (ms),
xlabel = Number of Constraints,
every axis legend/.append style={xshift=-10pt}
]
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,100)(7,100)(8,100)(9,100)};
\addplot+[draw opacity=0.5, thick, mark=square] plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,100)(7,100)(8,100)(9,100)};
\addplot+[mark=triangle] plot coordinates{(1,78)(2,62)(3,41)(4,44)(5,120)(6,96)(7,133)(8,133)(9,91)};
\legend{a,b,c}
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

相关内容