我正在创建一个简单的图表,其中的图带有标记。我使用 decorations.markings 库来创建间距均匀的标记。但是,靠近图表边界的标记被轴覆盖,请参见下面的示例 - 右侧的标记接近 1。我更愿意将标记放置在轴“上方”并完全可视化它们。有什么想法可以做到这一点吗?感谢您的任何建议/提示!
\documentclass[]{minimal}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,trees,positioning,arrows,chains,
shapes.geometric,
decorations.pathreplacing,
decorations.pathmorphing,shapes,
matrix,shapes.symbols,automata,decorations.markings}
\makeatletter
\tikzset{
nomorepostactions/.code={\let\tikz@postactions=\pgfutil@empty},
mymark/.style 2 args={decoration={markings,
mark= between positions 0.05 and 1 step
(1/11)*\pgfdecoratedpathlength with{%
\tikzset{#2,every mark}\tikz@options
\pgfuseplotmark{#1}%
},
},
postaction={decorate},
/pgfplots/legend image post style={
mark=#1,#2,every path/.append style={nomorepostactions}
},
},
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[height=9cm,
width=13cm,
grid=major,
xmin=0,
xmax=1,
ymin=0,
ymax=1
]
\addplot [color=black,
line width=1pt,
mark size=3pt,
mymark={*}{mark options={draw=white,fill=black}}
] coordinates {
(0, 0)
(0.99,0.5)
(1, 1)
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
只需添加clip=false
选项axis
: