9
$\begingroup$

With Joined -> True, ListPlot's filling is solid by default. But note that the filling and the line have different shades:

ListPlot[
  Table[{x, Sin[x Pi]}, {x, 0, 1, 0.025}]
  , Filling -> Axis
  , Joined -> True
  , ImageSize -> Small
]

Mathematica graphics

AFAICT, one cannot get a curve with zero thickness:

ListPlot[
  Table[{x, Sin[x Pi]}, {x, 0, 1, 0.025}]
  , Filling -> Axis
  , Joined -> True
  , PlotStyle -> Thickness[0]
  , ImageSize -> Small
]

Mathematica graphics

Is that really true?


PS: yes, I know that I can muck with the curve's color and/or opacity to simulate a zero-thickness curve in this case. E.g.

ListPlot[
  Table[{x, Sin[x Pi]}, {x, 0, 1, 0.025}]
  , Filling -> Axis
  , Joined -> True
  , PlotStyle -> Opacity[0]
  , ImageSize -> Small
]

Mathematica graphics

But I just want to confirm that, indeed, Mathematica won't let you have a zero-thickness curve.

$\endgroup$
4
  • 5
    $\begingroup$ (you can also use PlotStyle -> None) $\endgroup$
    – anderstood
    Mar 4, 2017 at 23:19
  • $\begingroup$ A zero thickness curve would be invisible -- Maybe it does draw one. :) $\endgroup$
    – Michael E2
    Mar 5, 2017 at 4:17
  • 1
    $\begingroup$ Related: "Is it possible to draw really thin lines in Mathematica?" $\endgroup$ Mar 8, 2017 at 3:06
  • $\begingroup$ @AlexeyPopkov That's the one I was looking for but I only found (9189); thanks for linking it! $\endgroup$
    – Mr.Wizard
    Mar 8, 2017 at 5:49

2 Answers 2

4
$\begingroup$

No, you cannot draw a sub-pixel-width line, at least in Mathematcia 10 under Windows:

SeedRandom[4];
pts = RandomReal[1, {10, 2}];
Graphics[{AbsoluteThickness[0], Line @ pts}]
Graphics[{Thickness[0.000001], Line @ pts}]

enter image description here

As noted in other questions like How can the opacity of a dense data set be automatically chosen? the solution is to use an Opacity less than one, or PlotStyle -> None, even though this displeases you.

$\endgroup$
3
  • $\begingroup$ A zero-width line is not sillier than a zero-opacity line. They both produce the same visual effect. I think something is lost when the semantics of Thickness[0] are special-cased like this. There's something to be said for uniformity of interface. And I disagree with your answer's first sentence: one can draw a zero-pixel line, vacuously. $\endgroup$
    – kjo
    Mar 5, 2017 at 10:47
  • 1
    $\begingroup$ @kjo (1) I never said a zero-width line was silly. Sub-pixel-width lines are possible in other software; it seems entirely plausible that they would be supported in Mathematica. (2) If however they both produce the same visual effect then using opacity is a working solution, or work-around, which is all I can offer. (3) I agree, Thickness[0] or perhaps even worse AbsoluteThickness[0] producing a 1-pixel-width line doesn't make sense. (4) I did write sub-pixel-width rather than zero-width for a reason. $\endgroup$
    – Mr.Wizard
    Mar 5, 2017 at 18:42
  • $\begingroup$ Sorry, I did misread your post somewhat. $\endgroup$
    – kjo
    Mar 6, 2017 at 13:47
9
$\begingroup$

It turns out you can, in fact, get a line with zero thickness. You can do this by passing a negative thickness as an argument to Thickness.

For instance, in your code example,

ListPlot[Table[{x, Sin[x Pi]}, {x, 0, 1, 0.025}], Filling -> Axis, 
 Joined -> True, PlotStyle -> Thickness[-2], ImageSize -> Small]

Produces

enter image description here

This workaround does seen to have issues in other places, such as exporting the file, where it seems the magnitude of the thickness is used to produce the saved graphic.

$\endgroup$
2
  • $\begingroup$ This is new to me! Thanks for posting. :-) $\endgroup$
    – Mr.Wizard
    Mar 8, 2017 at 1:23
  • 2
    $\begingroup$ (+1) This works when Exporting to PDF, but not to EMF or PNG. $\endgroup$ Mar 8, 2017 at 3:04

Your Answer

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

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