Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider the following graphic:

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

fuzzy

(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?

share|improve this question
add comment

1 Answer 1

up vote 13 down vote accepted

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

share|improve this answer
    
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.) –  Mr.Wizard Nov 14 '12 at 2:08
    
@Mr.W, weird indeed. –  kguler Nov 14 '12 at 2:15
2  
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. –  wxffles Nov 14 '12 at 2:21
1  
@MikeHoneychurch Haven't you heard about RandomOptions[]? :D –  belisarius Nov 14 '12 at 3:19
1  
Jut read Bretts answer that Mr Wizard linked to. Missed that Q&A at the time. I wonder what other options work like directives? –  Mike Honeychurch Nov 14 '12 at 3:37
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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