How can I obtain the exact opposite of the command restrict y to domain
? I have data in a table and I would like to color points inside [min:max] as black, and points outside [min,max] as red. I figured out how to place the black data by means of the restrict y to domain
option, but I don't know how to do the opposite for the "red data".
[Tex/LaTex] Opposite command of “restrict y to domain”
pgfplots
Best Answer
This is what
y filter
is for (it's whatrestrict y to domain
uses internally as well). Withiny filter/.code
, you have access to the current y coordinate and can run tests on it. At the end of the code, the current content of\pgfmathresult
is used as the new y coordinate.In your case, you can use a filter like
to restrict the range to points less than 5 or greater than 10. The
or(...)
statement will evaluate to zero otherwise, leading to a division by zero, which causes the points to quietly be discarded.You can wrap this in a convenience style, of course, like in this example: