When using dotted line style in a pgfplot, I realised that the dots are really square dots.

enter image description here

Usually most people associate dot with a filled circle(or is it just me?). And I know that there are workarounds to get the 'real dotted' line style. I am curious to know why pgfplot associates dot with a square dot, by default, in line style.

Here is source for the above figure:

  xlabel= $x$,
  ylabel= $y$,
  ymax = 6,
  legend columns=-1,
\addplot[mark=none, black, dotted] coordinates {(0,2) (5,2)};
\addplot[mark=none, black,thick, dotted] coordinates {(0,3) (5,3)};
\addplot[mark=none, black, very thick,dotted] coordinates {(0,4) (5,4)};
\addplot[mark=none, black, ultra thick,dotted] coordinates {(0,5) (5,5)};

\node at (axis cs:2.5, 1.8){default};
\node at (axis cs:2.5, 2.8){thick};
\node at (axis cs:2.5, 3.8){very thick};
\node at (axis cs:2.5, 4.8){ultra thick};

  • 1
    In text you use glyphs of a font, so a dot it easy, but in tikz you have to draw; and squares are easier and faster to draw than circles. The answers in the linked question show this. – Ulrike Fischer Jan 3 '18 at 9:02
  • The line styles come from TikZ I think, hence the tag. – Torbjørn T. Jan 3 '18 at 9:27

This is not a TeX or any TeX package issue but how PDF specifications are defined. pgfplots relies on TikZ and TikZ relies on PS/PDF instructions that are finally used inside the end result.

Dotted and dash-dotted lines are short lines drawn on and off very much like a TikZ decoration. For example if you add line cap=round you see the difference.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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