
我想繪製一條線,其中標記會剔除一部分線而不是顯示出來(如果有辦法在標記周圍留出一點空間,那將會很有用)。將標記畫成白色並不總是有效,即當情節背後有任何東西時。
有沒有辦法將標記添加到繪圖的剪輯路徑中,以便在被剔除的部分中它會是透明的而不是白色的?
\documentclass{minimal}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[height=3cm, width=10cm]
\addplot[fill=blue!20,draw=none,mark=none] coordinates{(0,0) (0,5) (5,5) (5,0)};
\addplot[mark=square*, mark options={scale=2, fill=white, draw=white},
samples=10] {x};
\addplot[only marks,samples=10] {x + 2*rand};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
除非某些高級用戶證明我是錯的,否則我會說:這是不可能的(無需付出相當大的努力)。
標記以特殊的方式、特殊的順序繪製,並特別考慮剪切路徑(標記路徑永遠不應該被剪切)等等。
\addplot[clip]
如果添加對的支援(將是功能請求),也許這是可能的。