PGFPlots – Filled Markers Without Border

pgfplots

I am trying to draw a PGF plot with markers only. I want the markers to be filled squares, but pgfplots keeps adding a differently colored border to these marks.

How can I stop that from happening? I want plain filled squares consisting of one color each.

what I don't want

MWE:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[tiny]
\addplot[
    mark=square*,
    only marks,
    mark options={draw=none}, % this line does not do anything
    scatter] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

Best Answer

You have to play with scatter/use mapped color option; in this case, to "remove" the border, you can set both draw and fill with the same color or you can set the draw opacity=0. The latter method makes markers' size narrow as the border is removed while the former method keeps the markers' size.

The complete example:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}
\begin{tikzpicture}
\begin{axis}[tiny]
\addplot[
    mark=square*,
    only marks,
    scatter,
    scatter/use mapped color=
        {draw opacity=0,fill=mapped color}% to remove the border
        %{draw=mapped color,fill=mapped color}% for same size
    ] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

The result:

enter image description here