I want to plot a line, where the markers knock out a piece of the line instead of being displayed (it would be useful if there was a way to leave a bit of space around a marker, too). Drawing the marks white doesn't always work, i.e. when anything is behind the plot.

Is there a way to add the markers to the plot's clip path, so it will be transparent in the knocked-out parts instead of white?

    \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};

enter image description here

  • Markers are not destructive in the sense that they don't remove the parts of the plot they are placed on. They are overdrawn so they can't remove a part of the path unless a certain decoration or something similar is utilized. Also you need \usetikzlibrary{plotmarks} in your MWE. – percusse Apr 13 '13 at 18:53

Unless I am proven wrong by some power-user, I would say: this is impossible (without considerable effort).

Markers are drawn in a special way, in a special sequence, and with special consideration of the clip path (marker paths should never be clipped) etc etc. Taking all that into account might prove to be difficult.

Perhaps it would be possible if support for \addplot[clip] was added (would be a feature request).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.