2

I'm trying to make a scatter plot from a .csv without any coloring. I'm using pgfplots

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}

\begin{document}

\pgfplotstableread[col sep = comma]{mytable.csv}\mytable

\begin{tikzpicture}
\begin{axis}[%
    axis lines = left,
    xlabel = x,
    ylabel = y,
]

\addplot[scatter, only marks] table [%
x = x, 
y = y, 
col sep = comma]{\mytable};

\end{axis}
\end{tikzpicture}

\end{document}

And in mytable.csv:

x,y
0,3
1,4
2,1
3,2
4,9
5,0

When I compile this everything looks nice, except the dots are colored. Is there a way to make all the markers black? Sorry if this is a dumb question

Edit:

This is what I ended doing (based off of the answers I got -- thanks!):

\addplot[only marks, mark options = {black}]

For some reason, if I left scatter in the \addplot options it wouldn't let me change the color of the marks. Right now everything is working great with no errors

  • welcome to tex.se! how you imagine, that we can test your code? it is not fun to write missing part that your code became compilable ... please extend it to complete small document beginning with \documentclass{...} and ending with \end{document}. – Zarko Aug 10 '17 at 14:05
  • @Zarko My bad, just edited it! – Jack Sullivan Aug 10 '17 at 14:18
1

Edit 1: After checking warning messages.

In this case removing scatter from \addplot options also works. Here is an MWE:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
axis lines = left,
xlabel = x,
ylabel = y,
]
\addplot[only marks] table [%
x = x, 
y = y, 
col sep = comma]{
    x, y
    2,3
     4,5
     3, 8
 };
\end{axis}
\end{tikzpicture}
\end{document}

The above produces:

black scatter mark

  • This looks great, but now I get a bunch of warnings saying: Package pgfplots Warning: scatter/classes: can't find class for '-2'!? Please make sure you have specified 'scatter src=explicit symbolic'. Ignoring class '-2' (this message will not come again). on input line 75.? – Jack Sullivan Aug 10 '17 at 14:31
  • you need mark options={black} or whichever properties. classes are for scatter class plots – percusse Aug 10 '17 at 14:47
  • @percusse would I put that in the options to \addplot? – Jack Sullivan Aug 10 '17 at 14:57
  • I missed the warnings in TeX-studio. I am not sure how to do it with scatter option enabled and without using style for classes. However, if you remove scatter from your original list of options (Edited MWE) then it works. In this case, you can also add ` mark options={blue}` (or any property)as percusse mentioned. – Adarsh Aug 10 '17 at 15:03

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.