I would like to create a data visualization in TikZ. I am using the following code:
\documentclass{standalone}
\usepackage{filecontents}
\usepackage{tikz}
\usetikzlibrary{datavisualization}
\begin{filecontents}{test.csv}
x y
-3 5
-2 7
-1 2
0 5
1 4
2 8
3 3
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\datavisualization
[
scientific axes,
all axes={length=5cm},
x axis={label=x, attribute=x, min value=-2, max value=2},
y axis={label=y, attribute=y, min value=0, max value=10},
visualize as line,
]
data[read from file=test.csv, separator={\space}];
\end{tikzpicture}
\end{document}
How can I achieve that only a range ([-2, 2] in this case) of the csv file is used? It causes drawing errors, and loading unnecessary lines is time consuming when using large csv files.

\datavisualizationinstead ofpgfplots(just curious, I didn't know about thistikz's data feature) – Guilherme Zanotelli Sep 23 '16 at 06:53pgfplotsis older and therefore is more developed thandatavisualization. I have usedpgfplotsa lot and I know that there are MANY customizable options for plotting, especially for standardizing plots (you can use global options) so, IMHO change topgfplotsif you are still in time. – Guilherme Zanotelli Sep 23 '16 at 07:16pgfplotsor to cut the range in the csv file by hand. I chosedatavisualizationbecause I did all of my plots with TikZ, so I was just looking up its manual to see how to do plots. – braxlan Sep 23 '16 at 09:08\datavisualiyation(I looked for it and didn't found any, so posted that one). I would say that for future plots, future you would thank you for switching topgfplots. But for the current document your doing, it's really up to you. – Guilherme Zanotelli Sep 23 '16 at 13:12