3

I have a data set with multiple columns, where some entries are blank. I want to import and plot this data using tikzpicture. However, the resulting graph looks like some values are repeated. Can anyone see an error or suggest a better approach for what I want to do?

simultation_results.dat::
dest    ds1     ds2         ds3       ds4
5       2       43                    5
6       32                  34        9
7       7       125         54        3
8       98                  4         3

Here is my code so far:

\begin{tikzpicture}
\begin{axis}
\addplot+ [ only marks,
        scatter,
        mark=x] table [x=dest, y=ds1] {simulation_results.dat};
\addplot+ [ only marks,
        scatter,
        mark=+] table [x=dest, y=ds2] {simulation_results.dat};
\addplot+ [ only marks,
        scatter,
        mark=-] table [x=dest, y=ds3] {simulation_results.dat};
\addplot+ [ only marks,
        scatter,
        mark=triangle*] table [x=dest, y=ds4] {simulation_results.dat};

\end{axis}
\end{tikzpicture}

Here is the resulting plot. Notice that some data points are repeated horizontally (they should not be)

screwed-up plot

2

Finally, I used a filter and back-filled the empty columns with 0. Since 0 will not occur in my dataset, I ignore those values in the plot.

Solution found here: How to hide empty (value 0) ybars with pgfplots?

simultation_results.dat::
dest    ds1     ds2         ds3       ds4
5       2       43          0         5
6       32      0           34        9
7       7       125         54        3
8       98      0           4         3


\addplot+ [ 
    y filter/.expression={y==0 ? nan : y*1000000},
    only marks,
    scatter,
    mark=x] table [x=dest, y=ds1] {simulation_results.dat};

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.