2
$\begingroup$
Graphics[{
  Line[{{# - 1, -0.5}, {# - 1, 5.5}} & /@ Range[6]],
  Line[{{-0.5, # - 1}, {5.5, # - 1}} & /@ Range[6]]
  }]

There are two kinds of lines in this simple picture, some lines look sharp and others look blurry. How can I avoid this effect?

If I zoom in the graphics by dragging the controlled-corner, the blurry effect still exists with different lines.

enter image description here

$\endgroup$
0

3 Answers 3

4
$\begingroup$

This seems to be connected to Antialiasing (which set to Falseproduces crisp lines):

g = Graphics[{Line[{{# - 1, -0.5}, {# - 1, 5.5}} & /@ Range[6]], 
    Line[{{-0.5, # - 1}, {5.5, # - 1}} & /@ Range[6]]}];

Grid[{{g, Style[g, Antialiasing -> False]}}]

Mathematica graphics

$\endgroup$
2
1
$\begingroup$

I was able to replicate the cosmetic glitch but cannot explain why it occurs.
Anyway, here are some options to minimize the effect.

You could use Gridlines:

Graphics[{}, GridLines -> {Range[6], Range[6]}, PlotRange -> {{1, 6}, {1, 6}},  
PlotRangePadding -> 0.5]

gridlines


Or Thin:

Graphics[{Thin, 
Line[{{# - 1, -0.5}, {# - 1, 5.5}} & /@ Range[6]], 
Line[{{-0.5, # - 1}, {5.5, # - 1}} & /@ Range[6]]}]

pic2


Or Thickness:

Graphics[{Thickness[.001], 
Line[{{# - 1, -0.5}, {# - 1, 5.5}} & /@ Range[6]], 
Line[{{-0.5, # - 1}, {5.5, # - 1}} & /@ Range[6]]}]

pic3

$\endgroup$
2
  • $\begingroup$ I get the same result by using your first method, but Thin and Thickness contribute nothing. Have you changed the opacity in last two methods? $\endgroup$ Commented Oct 15, 2013 at 2:58
  • $\begingroup$ No opacity changes in the final two pictures. I should mention that I am using a Mac computer with OS X 10.8.5, Mathematica 9.0.1. $\endgroup$
    – DavidC
    Commented Oct 15, 2013 at 10:36
0
$\begingroup$
Graphics[{
  EdgeForm@{Black}, Opacity@0,
  Table[Rectangle[{0, 0}, {i, 5}], {i, 5}],
  Table[Rectangle[{0, 0}, {5, i}], {i, 5}]
  }]

enter image description here

$\endgroup$

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