Consider the following graphic:

g = Graphics[{Circle[], Table[Line[{{-1, i}, {1, i}}], {i, -1, 1, 0.2}]}, ImageSize -> 150]


(You may need to look directly at the image because stackexchange seems to munge them).

You will note that the first and fourth lines from the top are quite crisp, while the third line is particularly fuzzy. This is because in the antialiasing process, the first and fourth line end up on a row on pixels, while the third is split between two rows.

If we turn antialiasing off:

Style[g, Antialiasing -> False]

enter image description here

(direct link)

We get all the lines nice and crisp, but of course the circle gets the jaggies.

What I'd like to do is to be able to adjust any horizontal (or vertical lines), so that they are antialiased to a single row (or column) of pixels. Everything else, including angled lines would remain as is. Any ideas?


1 Answer 1


You can use different settings for Antialiasing for different graphics primitives if you wrap each with Style:

 g2 = Graphics[{Style[Circle[], Antialiasing -> True], 
 Table[Style[Line[{{-1, i}, {1, i}}], 
 Antialiasing -> False], {i, -1, 1, 0.2}]}, ImageSize -> 250]

enter image description here

  • $\begingroup$ You don't even need Style; this weird syntax works: Graphics[{Antialiasing -> True, Circle[], Antialiasing -> False, Table[Line[{{-1, i}, {1, i}}], {i, -1, 1, 0.2}]}, ImageSize -> 250] (Antialiasing -> True could actually be omitted here but I leave it for illustration.) $\endgroup$
    – Mr.Wizard
    Nov 14, 2012 at 2:08
  • $\begingroup$ @Mr.W, weird indeed. $\endgroup$
    – kglr
    Nov 14, 2012 at 2:15
  • 2
    $\begingroup$ This is quite nifty. My new favourite rule is: Line[n : ({{a_, _}, {a_, _}} | {{_, b_}, {_, b_}})] -> {Antialiasing -> False, Line[n]}. The next challenge is to make it work with arrows. $\endgroup$
    – wxffles
    Nov 14, 2012 at 2:21
  • 1
    $\begingroup$ @MikeHoneychurch Haven't you heard about RandomOptions[]? :D $\endgroup$ Nov 14, 2012 at 3:19
  • 1
    $\begingroup$ Jut read Bretts answer that Mr Wizard linked to. Missed that Q&A at the time. I wonder what other options work like directives? $\endgroup$ Nov 14, 2012 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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