调整标记边缘样式,与 pgfplots 中的线条样式无关

调整标记边缘样式,与 pgfplots 中的线条样式无关

我现在正在努力绘制一个带有虚线和标记的漂亮线图。我在下面的代码中总结了这一点。那里似乎线型(虚线)用于 markeredge 线型,这不是我想要的。有人知道怎么解决这个问题吗?使用“填充”标记时看起来相当混乱。

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
  \begin{axis}[
      xlabel={$xlabel$},
      ylabel={ylabel},
      clip mode=individual,
      xmin=0.4, xmax=4.1,
      ymin=0.001, ymax=0.2,
      axis on top,
      width=12cm,
      height=12cm,
      ]
      \addplot [thick,dashed, blue, mark=o, mark size=5, mark options={rotate=180}]
      coordinates {
      (0.5,0.050434357296103)
      (1,0.0078648549533149)
      (1.5,0.0106056739726252)
      (2,0.0693259848345091)
      (2.5,0.0521069487623915)
      (3,0.0870245544201076)
      (4,0.121893601793102)
      };
      \addplot [thick,dashed, green, mark=*, mark size=5]
      coordinates {
      (0.5,0.12)
      (1,0.15)
      (3,0.18)
      };          
  \end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

答案1

您可以使用solidmark options这样标记边框就不会继承dashed样式:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
  \begin{axis}[
      xlabel={$xlabel$},
      ylabel={ylabel},
      clip mode=individual,
      xmin=0.4, xmax=4.1,
      ymin=0.001, ymax=0.2,
      axis on top,
      width=12cm,
      height=12cm,
      ]
      \addplot [thick,dashed, blue, mark=o, mark size=5, mark options={rotate=180,solid}]
      coordinates {
      (0.5,0.050434357296103)
      (1,0.0078648549533149)
      (1.5,0.0106056739726252)
      (2,0.0693259848345091)
      (2.5,0.0521069487623915)
      (3,0.0870245544201076)
      (4,0.121893601793102)
      };
      \addplot [thick,dashed, green, mark=*, mark size=5,mark options={solid}]
      coordinates {
      (0.5,0.12)
      (1,0.15)
      (3,0.18)
      };          
  \end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

如果要将其应用于所有标记,最好使用

 \tikzset{every mark/.append style={solid}}

因此您不必每次都使用该选项:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\tikzset{every mark/.append style={solid}}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
  \begin{axis}[
      xlabel={$xlabel$},
      ylabel={ylabel},
      clip mode=individual,
      xmin=0.4, xmax=4.1,
      ymin=0.001, ymax=0.2,
      axis on top,
      width=12cm,
      height=12cm,
      ]
      \addplot [thick,dashed, blue, mark=o, mark size=5]
      coordinates {
      (0.5,0.050434357296103)
      (1,0.0078648549533149)
      (1.5,0.0106056739726252)
      (2,0.0693259848345091)
      (2.5,0.0521069487623915)
      (3,0.0870245544201076)
      (4,0.121893601793102)
      };
      \addplot [thick,dashed, green, mark=*, mark size=5]
      coordinates {
      (0.5,0.12)
      (1,0.15)
      (3,0.18)
      };          
  \end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

相关内容