0

I have the following code (taken as an example from: Scatterplot with data from CSV file and trendline) which plots a 3d scatterplot from a csv file.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots, pgfplotstable}
\usepackage{filecontents}

\begin{filecontents}{table.dat}
 x y
 0 1
100 3
150 2
200 5
300 6
\end{filecontents}

\begin{document}

\begin{tikzpicture}
     \begin{axis}[
        axis x line=middle,
        axis y line=middle,
        enlarge y limits=true,
        width=15cm, height=8cm,     % size of the image
        grid = major,
        grid style={dashed, gray!30},
         ylabel=steps,
         xlabel=$n$,
         legend style={at={(0.1,-0.1)}, anchor=north}
      ]        
     \addplot[only marks] table  {table.dat};

 \end{axis}
 \end{tikzpicture}

 \end{document}

Is there any way I can have only a few points plotted from the csv file?

  • 2
    Welcome! Yes, there sure is. However, users will be much more eager to help you if you (a) provide them with a complete document that starts with \documentclass and ends with \end{document} and (b) add a small sample data file that we can play with. –  Oct 30 '19 at 00:08
  • 1
    If you do not want to provide us with a working example, let mention that you are most likely looking for a filter, which can for instance select points with an appropriate \corrdindex. If you want to have this spelled out, please go the extra mile and provide us with something that makes it us easier to write an answer. –  Oct 30 '19 at 02:32
  • I apologize for the delay. I have updated the code with a working simple example of a scatter plot. However, I will lookup \corrdindex see if I can use that command. Thank you so much! – Aditya Dendukuri Oct 31 '19 at 01:33
  • \corrdindex is the perfect answer, worked like a charm! Thank you @Schrödinger'scat for the answer! – Aditya Dendukuri Oct 31 '19 at 01:39
  • You're welcome. (I realized that I mistyped \coordindex but I guess you figured that out.) Please let me know if your problem solved, or there is anything to do. –  Oct 31 '19 at 02:02
  • Yes my issue is solved. – Aditya Dendukuri Oct 31 '19 at 16:25

0 Answers0